if args: torrent_dir = args[0] config["torrent_dir"] = platform.decode_from_filesystem(torrent_dir) else: torrent_dir = config["torrent_dir"] torrent_dir, bad = platform.encode_for_filesystem(torrent_dir) if bad: raise BTFailure(_("Warning: ") + config["torrent_dir"] + _(" is not a directory")) if not os.path.isdir(torrent_dir): raise BTFailure(_("Warning: ") + torrent_dir + _(" is not a directory")) # the default behavior is to save_in files to the platform # get_save_dir. For launchmany, if no command-line argument # changed the save directory then use the torrent directory. if config["save_in"] == platform.get_save_dir(): config["save_in"] = config["torrent_dir"] except BTFailure, e: print _("error: ") + unicode(e.args[0]) + _("\nrun with no args for parameter explanations") sys.exit(1) except KeyboardInterrupt: sys.exit(1) # inject_main_logfile() class LaunchManyApp(object): class LogHandler(logging.Handler): def __init__(self, level, displayer): logging.Handler.__init__(self, level) self.displayer = displayer
config['torrent_dir'] = decode_from_filesystem(torrent_dir) else: torrent_dir = config['torrent_dir'] torrent_dir,bad = encode_for_filesystem(torrent_dir) if bad: raise BTFailure(_("Warning: ")+config['torrent_dir']+ _(" is not a directory")) if not os.path.isdir(torrent_dir): raise BTFailure(_("Warning: ")+torrent_dir+ _(" is not a directory")) # the default behavior is to save_in files to the platform # get_save_dir. For launchmany, if no command-line argument # changed the save directory then use the torrent directory. if config['save_in'] == platform.get_save_dir(): config['save_in'] = config['torrent_dir'] except BTFailure, e: print _("error: ") + unicode(e.args[0]) + \ _("\nrun with no args for parameter explanations") sys.exit(1) except KeyboardInterrupt: sys.exit(1) inject_main_logfile() class LaunchManyApp(object): class LogHandler(logging.Handler): def __init__(self, level, displayer): logging.Handler.__init__(self,level)
def get_save_dir(): return decode_from_filesystem(platform.get_save_dir())
smart_gettext_and_install('bittorrent', locale_root, languages=[config['language']]) if config.has_key('bind') and config['bind'] != '': bind_tracker_connection(config['bind']) if config.has_key('launch_on_startup'): enforce_shortcut(config, log_func=sys.stderr.write) if os.name == 'nt' and config.has_key('enforce_association'): enforce_association() if config.has_key('save_in') and config['save_in'] == '' and \ (not config.has_key("save_as") or config['save_as'] == '' ) \ and uiname != 'bittorrent': config['save_in'] = decode_from_filesystem(get_save_dir()) incomplete = decode_from_filesystem(get_incomplete_data_dir()) if config.get('save_incomplete_in') == '': config['save_incomplete_in'] = incomplete if config.get('save_incomplete_in') == get_old_incomplete_data_dir(): config['save_incomplete_in'] = incomplete if uiname == "test-client" or (uiname.startswith("bittorrent") and uiname != 'bittorrent-tracker'): if not config.get('ask_for_save'): # we check for existance, so things like "D:\" don't trip us up. if (config['save_in'] and not os.path.exists(config['save_in'])): try: os.makedirs(config['save_in'])
if config.has_key("bind") and config["bind"] != "": bind_tracker_connection(config["bind"]) if config.has_key("launch_on_startup"): enforce_shortcut(config, log_func=sys.stderr.write) if os.name == "nt" and config.has_key("enforce_association"): enforce_association() if ( config.has_key("save_in") and config["save_in"] == "" and (not config.has_key("save_as") or config["save_as"] == "") and uiname != "bittorrent" ): config["save_in"] = decode_from_filesystem(get_save_dir()) incomplete = decode_from_filesystem(get_incomplete_data_dir()) if config.get("save_incomplete_in") == "": config["save_incomplete_in"] = incomplete if config.get("save_incomplete_in") == get_old_incomplete_data_dir(): config["save_incomplete_in"] = incomplete if uiname == "test-client" or (uiname.startswith("bittorrent") and uiname != "bittorrent-tracker"): if not config.get("ask_for_save"): # we check for existance, so things like "D:\" don't trip us up. if config["save_in"] and not os.path.exists(config["save_in"]): try: os.makedirs(config["save_in"]) except OSError, e: if e.errno == 2 or e.errno == 13: # no such file or directory # permission denied