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"
obexftp_prog = "/usr/local/obex/bin/obexftp"
-import sys, time
-import os, shutil
+import sys, os, shutil
+from time import sleep
import xml.dom.minidom
-from tempfile import mkstemp, mkdtemp
+from tempfile import mkstemp, mkdtemp, _candidate_tempdir_list
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)
-if len(sys.argv) < 2:
+if len(sys.argv) < 3:
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)
+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):
for entry in directories:
fullpath = "%s/%s" % (directory, entry.name)
if fullpath.startswith('//'): fullpath = fullpath[1:]
- time.sleep(1)
+ sleep(1)
recursive_list(fullpath)
def mcobex_list():