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
b4d9a6aa
Commit
b4d9a6aa
authored
19 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
new helpers.check_paths() function that creates LOGPATH and VCARDPATH
parent
b69bc501
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/common/gajim.py
+18
-0
18 additions, 0 deletions
src/common/gajim.py
src/common/helpers.py
+48
-0
48 additions, 0 deletions
src/common/helpers.py
src/common/logger.py
+9
-51
9 additions, 51 deletions
src/common/logger.py
src/gajim.py
+1
-0
1 addition, 0 deletions
src/gajim.py
with
76 additions
and
51 deletions
src/common/gajim.py
+
18
−
0
View file @
b4d9a6aa
...
...
@@ -18,6 +18,7 @@
##
import
os
import
sys
import
logging
import
mutex
...
...
@@ -38,6 +39,23 @@ log.addHandler(h)
logger
=
common
.
logger
.
Logger
()
DATA_DIR
=
'
../data
'
LOGPATH
=
os
.
path
.
expanduser
(
'
~/.gajim/logs
'
)
VCARDPATH
=
os
.
path
.
expanduser
(
'
~/.gajim/vcards
'
)
if
os
.
name
==
'
nt
'
:
try
:
# Documents and Settings\[User Name]\Application Data\Gajim\logs
LOGPATH
=
os
.
environ
[
'
appdata
'
]
+
'
/Gajim/Logs
'
VCARDPATH
=
os
.
environ
[
'
appdata
'
]
+
'
/Gajim/Vcards
'
except
KeyError
:
# win9x, ./logs
LOGPATH
=
'
Logs
'
LOGPATH
=
'
Vcards
'
try
:
LOGPATH
=
LOGPATH
.
decode
(
sys
.
getfilesystemencoding
())
VCARDPATH
=
VCARDPATH
.
decode
(
sys
.
getfilesystemencoding
())
except
:
pass
LANG
=
os
.
getenv
(
'
LANG
'
)
# en_US, fr_FR, el_GR etc..
if
LANG
:
LANG
=
LANG
[:
2
]
# en, fr, el etc..
...
...
This diff is collapsed.
Click to expand it.
src/common/helpers.py
+
48
−
0
View file @
b4d9a6aa
...
...
@@ -21,6 +21,8 @@ import sre
import
os
import
urllib
import
errno
import
sys
import
stat
import
gajim
from
common
import
i18n
...
...
@@ -43,6 +45,52 @@ def temp_failure_retry(func, *args, **kwargs):
else
:
raise
def
check_paths
():
LOGPATH
=
gajim
.
LOGPATH
VCARDPATH
=
gajim
.
VCARDPATH
dot_gajim
=
os
.
path
.
dirname
(
LOGPATH
)
if
os
.
path
.
isfile
(
dot_gajim
):
print
_
(
'
%s is file but it should be a directory
'
)
%
dot_gajim
print
_
(
'
Gajim will now exit
'
)
sys
.
exit
()
elif
os
.
path
.
isdir
(
dot_gajim
):
s
=
os
.
stat
(
dot_gajim
)
if
s
.
st_mode
&
stat
.
S_IROTH
:
# others have read permission!
os
.
chmod
(
dot_gajim
,
0700
)
# rwx------
if
not
os
.
path
.
exists
(
LOGPATH
):
print
_
(
'
creating %s directory
'
)
%
LOGPATH
os
.
mkdir
(
LOGPATH
,
0700
)
elif
os
.
path
.
isfile
(
LOGPATH
):
print
_
(
'
%s is file but it should be a directory
'
)
%
LOGPATH
print
_
(
'
Gajim will now exit
'
)
sys
.
exit
()
elif
os
.
path
.
isdir
(
LOGPATH
):
s
=
os
.
stat
(
LOGPATH
)
if
s
.
st_mode
&
stat
.
S_IROTH
:
# others have read permission!
os
.
chmod
(
LOGPATH
,
0700
)
# rwx------
if
not
os
.
path
.
exists
(
VCARDPATH
):
print
_
(
'
creating %s directory
'
)
%
VCARDPATH
os
.
mkdir
(
VCARDPATH
,
0700
)
elif
os
.
path
.
isfile
(
VCARDPATH
):
print
_
(
'
%s is file but it should be a directory
'
)
%
VCARDPATH
print
_
(
'
Gajim will now exit
'
)
sys
.
exit
()
elif
os
.
path
.
isdir
(
VCARDPATH
):
s
=
os
.
stat
(
VCARDPATH
)
if
s
.
st_mode
&
stat
.
S_IROTH
:
# others have read permission!
os
.
chmod
(
VCARDPATH
,
0700
)
# rwx------
else
:
# dot_gajim doesn't exist
if
dot_gajim
:
# is '' on win9x so avoid that
print
_
(
'
creating %s directory
'
)
%
dot_gajim
os
.
mkdir
(
dot_gajim
,
0700
)
if
not
os
.
path
.
isdir
(
LOGPATH
):
print
_
(
'
creating %s directory
'
)
%
LOGPATH
os
.
mkdir
(
LOGPATH
,
0700
)
if
not
os
.
path
.
isdir
(
VCARDPATH
):
print
_
(
'
creating %s directory
'
)
%
VCARDPATH
os
.
mkdir
(
VCARDPATH
,
0700
)
def
convert_bytes
(
string
):
suffix
=
''
...
...
This diff is collapsed.
Click to expand it.
src/common/logger.py
+
9
−
51
View file @
b4d9a6aa
...
...
@@ -18,59 +18,17 @@
##
import
os
import
sys
import
time
import
stat
import
common.gajim
from
common
import
i18n
_
=
i18n
.
_
import
helpers
LOGPATH
=
os
.
path
.
expanduser
(
'
~/.gajim/logs
'
)
if
os
.
name
==
'
nt
'
:
try
:
# Documents and Settings\[User Name]\Application Data\Gajim\logs
LOGPATH
=
os
.
environ
[
'
appdata
'
]
+
'
/Gajim/Logs
'
except
KeyError
:
# win9x, ./logs
LOGPATH
=
'
Logs
'
try
:
LOGPATH
=
LOGPATH
.
decode
(
sys
.
getfilesystemencoding
())
except
:
pass
class
Logger
:
def
__init__
(
self
):
dot_gajim
=
os
.
path
.
dirname
(
LOGPATH
)
if
os
.
path
.
isfile
(
dot_gajim
):
print
_
(
'
%s is file but it should be a directory
'
)
%
dot_gajim
print
_
(
'
Gajim will now exit
'
)
sys
.
exit
()
elif
os
.
path
.
isdir
(
dot_gajim
):
s
=
os
.
stat
(
dot_gajim
)
if
s
.
st_mode
&
stat
.
S_IROTH
:
# others have read permission!
os
.
chmod
(
dot_gajim
,
0700
)
# rwx------
if
not
os
.
path
.
exists
(
LOGPATH
):
print
_
(
'
creating %s directory
'
)
%
LOGPATH
os
.
mkdir
(
LOGPATH
,
0700
)
elif
os
.
path
.
isfile
(
LOGPATH
):
print
_
(
'
%s is file but it should be a directory
'
)
%
LOGPATH
print
_
(
'
Gajim will now exit
'
)
sys
.
exit
()
elif
os
.
path
.
isdir
(
LOGPATH
):
s
=
os
.
stat
(
LOGPATH
)
if
s
.
st_mode
&
stat
.
S_IROTH
:
# others have read permission!
os
.
chmod
(
LOGPATH
,
0700
)
# rwx------
else
:
# dot_gajim doesn't exist
if
dot_gajim
:
# is '' on win9x so avoid that
print
_
(
'
creating %s directory
'
)
%
dot_gajim
os
.
mkdir
(
dot_gajim
,
0700
)
if
not
os
.
path
.
isdir
(
LOGPATH
):
print
_
(
'
creating %s directory
'
)
%
LOGPATH
os
.
mkdir
(
LOGPATH
,
0700
)
pass
def
write
(
self
,
kind
,
msg
,
jid
,
show
=
None
,
tim
=
None
):
if
not
tim
:
...
...
@@ -92,7 +50,7 @@ class Logger:
if
not
show
:
show
=
'
online
'
if
common
.
gajim
.
config
.
get
(
'
log_notif_in_user_file
'
):
path_to_file
=
os
.
path
.
join
(
LOGPATH
,
ji
)
path_to_file
=
os
.
path
.
join
(
common
.
gajim
.
LOGPATH
,
ji
)
if
os
.
path
.
isdir
(
path_to_file
):
jid
=
'
gcstatus
'
msg
=
show
+
'
:
'
+
msg
...
...
@@ -105,7 +63,7 @@ class Logger:
if
common
.
gajim
.
config
.
get
(
'
log_notif_in_sep_file
'
):
files
.
append
(
'
notify.log
'
)
elif
kind
==
'
incoming
'
:
# we save time:recv:message
path_to_file
=
os
.
path
.
join
(
LOGPATH
,
ji
)
path_to_file
=
os
.
path
.
join
(
common
.
gajim
.
LOGPATH
,
ji
)
if
os
.
path
.
isdir
(
path_to_file
):
files
.
append
(
jid
)
else
:
...
...
@@ -114,7 +72,7 @@ class Logger:
show
=
msg
msg
=
''
elif
kind
==
'
outgoing
'
:
# we save time:sent:message
path_to_file
=
os
.
path
.
join
(
LOGPATH
,
ji
)
path_to_file
=
os
.
path
.
join
(
common
.
gajim
.
LOGPATH
,
ji
)
if
os
.
path
.
isdir
(
path_to_file
):
files
.
append
(
jid
)
else
:
...
...
@@ -124,7 +82,7 @@ class Logger:
msg
=
''
elif
kind
==
'
gc
'
:
# we save time:gc:nick:message
# create the folder if needed
ji_fn
=
os
.
path
.
join
(
LOGPATH
,
ji
)
ji_fn
=
os
.
path
.
join
(
common
.
gajim
.
LOGPATH
,
ji
)
if
os
.
path
.
isfile
(
ji_fn
):
os
.
remove
(
ji_fn
)
if
not
os
.
path
.
isdir
(
ji_fn
):
...
...
@@ -142,7 +100,7 @@ class Logger:
if
msg
and
isinstance
(
msg
,
unicode
):
msg
=
msg
.
encode
(
'
utf-8
'
)
for
f
in
files
:
path_to_file
=
os
.
path
.
join
(
LOGPATH
,
f
)
path_to_file
=
os
.
path
.
join
(
common
.
gajim
.
LOGPATH
,
f
)
if
os
.
path
.
isdir
(
path_to_file
):
return
# this does it rw-r-r by default but is in a dir with 700 so it's ok
...
...
@@ -155,12 +113,12 @@ class Logger:
def
__get_path_to_file
(
self
,
fjid
):
jid
=
fjid
.
split
(
'
/
'
)[
0
]
path_to_file
=
os
.
path
.
join
(
LOGPATH
,
jid
)
path_to_file
=
os
.
path
.
join
(
common
.
gajim
.
LOGPATH
,
jid
)
if
os
.
path
.
isdir
(
path_to_file
):
if
fjid
==
jid
:
# we want to read the gc history
path_to_file
=
os
.
path
.
join
(
LOGPATH
,
jid
+
'
/
'
+
jid
)
path_to_file
=
os
.
path
.
join
(
common
.
gajim
.
LOGPATH
,
jid
+
'
/
'
+
jid
)
else
:
#we want to read pm history
path_to_file
=
os
.
path
.
join
(
LOGPATH
,
fjid
)
path_to_file
=
os
.
path
.
join
(
common
.
gajim
.
LOGPATH
,
fjid
)
return
path_to_file
def
get_no_of_lines
(
self
,
fjid
):
...
...
This diff is collapsed.
Click to expand it.
src/gajim.py
+
1
−
0
View file @
b4d9a6aa
...
...
@@ -1224,6 +1224,7 @@ class Interface:
self
.
remote
=
None
def
__init__
(
self
):
helpers
.
check_paths
()
gajim
.
interface
=
self
self
.
default_values
=
{
'
inmsgcolor
'
:
gajim
.
config
.
get
(
'
inmsgcolor
'
),
...
...
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