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
7f44b602
Commit
7f44b602
authored
18 years ago
by
junglecow
Browse files
Options
Downloads
Patches
Plain Diff
- Use bytestrings instead of unicode for filesystem paths. See #2812 and close if fix works.
parent
35ecad11
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/configpaths.py
+23
-20
23 additions, 20 deletions
src/common/configpaths.py
with
23 additions
and
20 deletions
src/common/configpaths.py
+
23
−
20
View file @
7f44b602
...
...
@@ -20,10 +20,11 @@ import tempfile
# happily pass to functions that operate on files and directories, so we can
# just leave it as is. Since these paths are meant to be internal to Gajim and
# not displayed to the user, Unicode is not really necessary here.
def
fse
(
s
):
'''
Convert from filesystem encoding if not already Unicode
'''
return
unicode
(
s
,
sys
.
getfilesystemencoding
())
#
# Update: Python stdlib seems broken, and uses sys.getdefaultencoding() instead
# of sys.getfilesystemencoding() for converting unicode paths in file operations.
# Additionally, PyGTK overrides defaultencoding to utf-8, overriding site.py.
# Therefore, we now use bytestrings and never unicode. (See #2812.)
class
ConfigPaths
:
def
__init__
(
self
,
root
=
None
):
...
...
@@ -38,13 +39,12 @@ class ConfigPaths:
# How are we supposed to know what encoding the environment
# variable 'appdata' is in? Assuming it to be in filesystem
# encoding.
self
.
root
=
os
.
path
.
join
(
fse
(
os
.
environ
[
u
'
appdata
'
]
)
,
u
'
Gajim
'
)
self
.
root
=
os
.
path
.
join
(
os
.
environ
[
'
appdata
'
],
'
Gajim
'
)
except
KeyError
:
# win9x, in cwd
self
.
root
=
u
''
self
.
root
=
''
else
:
# Unices
# Pass in an Unicode string, and hopefully get one back.
self
.
root
=
os
.
path
.
expanduser
(
u
'
~/.gajim
'
)
self
.
root
=
os
.
path
.
expanduser
(
'
~/.gajim
'
)
def
add_from_root
(
self
,
name
,
path
):
self
.
paths
[
name
]
=
(
True
,
path
)
...
...
@@ -77,8 +77,8 @@ def init():
paths
=
ConfigPaths
()
# LOG is deprecated
k
=
(
'
LOG
'
,
'
LOG_DB
'
,
'
VCARD
'
,
'
AVATAR
'
,
'
MY_EMOTS
'
)
v
=
(
u
'
logs
'
,
u
'
logs.db
'
,
u
'
vcards
'
,
u
'
avatars
'
,
u
'
emoticons
'
)
k
=
(
'
LOG
'
,
'
LOG_DB
'
,
'
VCARD
'
,
'
AVATAR
'
,
'
MY_EMOTS
'
)
v
=
(
'
logs
'
,
'
logs.db
'
,
'
vcards
'
,
'
avatars
'
,
'
emoticons
'
)
if
os
.
name
==
'
nt
'
:
v
=
map
(
lambda
x
:
x
.
capitalize
(),
v
)
...
...
@@ -86,9 +86,9 @@ def init():
for
n
,
p
in
zip
(
k
,
v
):
paths
.
add_from_root
(
n
,
p
)
paths
.
add
(
'
DATA
'
,
os
.
path
.
join
(
u
'
..
'
,
windowsify
(
u
'
data
'
)))
paths
.
add
(
'
HOME
'
,
fse
(
os
.
path
.
expanduser
(
'
~
'
))
)
paths
.
add
(
'
TMP
'
,
fse
(
tempfile
.
gettempdir
())
)
paths
.
add
(
'
DATA
'
,
os
.
path
.
join
(
'
..
'
,
windowsify
(
'
data
'
)))
paths
.
add
(
'
HOME
'
,
os
.
path
.
expanduser
(
'
~
'
))
paths
.
add
(
'
TMP
'
,
tempfile
.
gettempdir
())
try
:
import
svn_config
...
...
@@ -96,20 +96,23 @@ def init():
except
(
ImportError
,
AttributeError
):
pass
#for k, v in paths.iteritems():
# print "%s: %s" % (
k,
v)
#
for k, v in paths.iteritems():
#
print "%s: %s" % (
repr(k), repr(
v)
)
return
paths
gajimpaths
=
init
()
def
init_profile
(
profile
,
paths
=
gajimpaths
):
conffile
=
windowsify
(
u
'
config
'
)
pidfile
=
windowsify
(
u
'
gajim
'
)
conffile
=
windowsify
(
'
config
'
)
pidfile
=
windowsify
(
'
gajim
'
)
if
len
(
profile
)
>
0
:
conffile
+=
u
'
.
'
+
profile
pidfile
+=
u
'
.
'
+
profile
pidfile
+=
u
'
.pid
'
conffile
+=
'
.
'
+
profile
pidfile
+=
'
.
'
+
profile
pidfile
+=
'
.pid
'
paths
.
add_from_root
(
'
CONFIG_FILE
'
,
conffile
)
paths
.
add_from_root
(
'
PID_FILE
'
,
pidfile
)
# for k, v in paths.iteritems():
# print "%s: %s" % (repr(k), repr(v))
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