Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
1ea3f10a
Commit
1ea3f10a
authored
19 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
try to guess encoding when we add a new table and a new log line when we migrate
parent
41d31cc3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/migrate_logs_to_dot9_db.py
+18
-3
18 additions, 3 deletions
scripts/migrate_logs_to_dot9_db.py
with
18 additions
and
3 deletions
scripts/migrate_logs_to_dot9_db.py
+
18
−
3
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment