From 64c259e2ddab9053efc5224663b2b898ca7336e4 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 3 Oct 2004 13:33:03 +0000 Subject: [PATCH] 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. git-svn-id: file:///home/phd/archive/SVN/mc-extfs/trunk@32 1a6e6372-1aea-0310-bd00-dc960550e1df --- obexftp | 50 +++++++++++++++++++++++++++++++++++++----------- obexftp-ANNOUNCE | 6 ++++++ 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/obexftp b/obexftp index 6d8f72a..fb18355 100755 --- a/obexftp +++ b/obexftp @@ -60,13 +60,15 @@ Commander shows the same cached VFS image. Exit Midnight Commander and 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 " __copyright__ = "Copyright (C) 2004 PhiloSoft Design" @@ -75,29 +77,55 @@ __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): @@ -216,7 +244,7 @@ def recursive_list(directory='/'): 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(): diff --git a/obexftp-ANNOUNCE b/obexftp-ANNOUNCE index bba6054..ff943f5 100644 --- a/obexftp-ANNOUNCE +++ b/obexftp-ANNOUNCE @@ -6,6 +6,12 @@ WHAT IS IT binary. +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 for reporting the bug. Now I use files -- 2.39.5