Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gajim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
196
Issues
196
List
Boards
Labels
Service Desk
Milestones
Merge Requests
21
Merge Requests
21
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim
Commits
1ea3f10a
Commit
1ea3f10a
authored
Nov 25, 2005
by
Yann Leboulanger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to guess encoding when we add a new table and a new log line when we migrate
parent
41d31cc3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
scripts/migrate_logs_to_dot9_db.py
scripts/migrate_logs_to_dot9_db.py
+18
-3
No files found.
scripts/migrate_logs_to_dot9_db.py
View file @
1ea3f10a
...
...
@@ -90,6 +90,19 @@ def get_jid(dirname, filename):
jid
=
jid
.
lower
()
return
jid
def
decode_string
(
string
):
'''try to decode (to make it Unicode instance) given string'''
# by the time we go to iso15 it better be the one else we show bad characters
encodings
=
(
sys
.
getfilesystemencoding
(),
'utf-8'
,
'iso-8859-15'
)
for
encoding
in
encodings
:
try
:
string
=
string
.
decode
(
encoding
)
except
UnicodeError
:
continue
return
string
return
None
def
visit
(
arg
,
dirname
,
filenames
):
print
'Visiting'
,
dirname
for
filename
in
filenames
:
...
...
@@ -97,9 +110,8 @@ def visit(arg, dirname, filenames):
# notifications are also in contact log file
if
filename
==
'notify.log'
:
continue
try
:
filename
.
decode
(
'utf-8'
)
except
:
filename
=
decode_string
(
filename
)
if
not
filename
:
continue
path_to_text_file
=
os
.
path
.
join
(
dirname
,
filename
)
if
os
.
path
.
isdir
(
path_to_text_file
):
...
...
@@ -137,6 +149,9 @@ def visit(arg, dirname, filenames):
# sent ==> chat_msg_sent, status ==> status
type
=
splitted_line
[
1
]
# line[1] has type of logged message
message_data
=
splitted_line
[
2
:]
# line[2:] has message data
message_data
=
decode_string
(
message_data
)
if
not
message_data
:
continue
# line[0] is date,
# some lines can be fucked up, just drop them
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment