If the directory or the file is not writeable - try to put the logfile in a temporary directory, usually /tmp.
git-svn-id: file:///home/phd/archive/SVN/mc-extfs/trunk@32
1a6e6372-1aea-0310-bd00-
dc960550e1df
restart it.
If something goes wrong set the logging level (see setLevel() below) to INFO
restart it.
If something goes wrong set the logging level (see setLevel() below) to INFO
-or DEBUG and look in the obexftp-mcextfs.log file(s).
-
+or DEBUG and look in the obexftp-mcextfs.log file. The file is put in the same
+directory as the transport file, if it possible; if not the file will be put
+into a temporary directory, usually /tmp, or /var/tmp, or whatever directory
+is named in $TMP environment variable.
-__version__ = "1.2.0"
-__revision__ = "$Id: obexftp,v 1.17 2004/09/25 16:13:39 phd Exp $"
-__date__ = "$Date: 2004/09/25 16:13:39 $"[7:-2]
+__version__ = "1.2.1"
+__revision__ = "$Id: obexftp,v 1.18 2004/10/03 13:33:03 phd Exp $"
+__date__ = "$Date: 2004/10/03 13:33:03 $"[7:-2]
__author__ = "Oleg Broytmann <phd@phd.pp.ru>"
__copyright__ = "Copyright (C) 2004 PhiloSoft Design"
__author__ = "Oleg Broytmann <phd@phd.pp.ru>"
__copyright__ = "Copyright (C) 2004 PhiloSoft Design"
obexftp_prog = "/usr/local/obex/bin/obexftp"
obexftp_prog = "/usr/local/obex/bin/obexftp"
-import sys, time
-import os, shutil
+import sys, os, shutil
+from time import sleep
-from tempfile import mkstemp, mkdtemp
+from tempfile import mkstemp, mkdtemp, _candidate_tempdir_list
import logging
logger = logging.getLogger('obexftp-mcextfs')
import logging
logger = logging.getLogger('obexftp-mcextfs')
-logger.addHandler(logging.FileHandler('obexftp-mcextfs.log'))
+log_err_handler = logging.StreamHandler(sys.stderr)
+logger.addHandler(log_err_handler)
logger.setLevel(logging.ERROR)
logger.setLevel(logging.ERROR)
logger.error("""\
ObexFTP Virtual FileSystem for Midnight Commander version %s
Author: %s
%s
logger.error("""\
ObexFTP Virtual FileSystem for Midnight Commander version %s
Author: %s
%s
+
+This is not a program. It is ObexFTP Virtual FileSystem for Midnight Commander.
Put it in /usr/lib/mc/extfs. For more information read the source!""",
__version__, __author__, __copyright__
)
sys.exit(1)
Put it in /usr/lib/mc/extfs. For more information read the source!""",
__version__, __author__, __copyright__
)
sys.exit(1)
+tempdirlist = _candidate_tempdir_list()
+tempdirlist.insert(0, os.path.abspath(os.path.dirname(sys.argv[2])))
+
+found = False
+for tempdir in tempdirlist:
+ try:
+ logfile_name = os.path.join(tempdir, 'obexftp-mcextfs.log')
+ logfile = open(logfile_name, 'w')
+ except IOError:
+ pass
+ else:
+ found = True
+ logfile.close()
+ break
+
+if not found:
+ logger.error("Cannot initialize error log file in directories %s" % str(tempdirlist))
+ sys.exit(1)
+
+logger.removeHandler(log_err_handler)
+logger.addHandler(logging.FileHandler(logfile_name))
+
+
# Parse ObexFTP XML directory listings
class DirectoryEntry(object):
# Parse ObexFTP XML directory listings
class DirectoryEntry(object):
for entry in directories:
fullpath = "%s/%s" % (directory, entry.name)
if fullpath.startswith('//'): fullpath = fullpath[1:]
for entry in directories:
fullpath = "%s/%s" % (directory, entry.name)
if fullpath.startswith('//'): fullpath = fullpath[1:]
recursive_list(fullpath)
def mcobex_list():
recursive_list(fullpath)
def mcobex_list():
+WHAT'S NEW in version 1.2.1 (2004-10-03)
+ Put error logfile in the same directory as the transport file. If the
+directory or the file is not writeable - try to put the logfile in a temporary
+directory, usually /tmp.
+
+
WHAT'S NEW in version 1.2.0 (2004-09-27)
Fixed a major bug with blocked read from a pipe. Many thanks to
Marius Konitzer <m.konitzer@gmx.de> for reporting the bug. Now I use files
WHAT'S NEW in version 1.2.0 (2004-09-27)
Fixed a major bug with blocked read from a pipe. Many thanks to
Marius Konitzer <m.konitzer@gmx.de> for reporting the bug. Now I use files