コード例 #1
0
ファイル: migbox.py プロジェクト: bertl4398/MiGBox
def start_server(args, basedir):
    if args.config:
        _vars = read_config(args.config, server=True)
    else:
        # try to read default configuration file at default location
        config = os.path.join(basedir, "config", "server.cfg")
        _vars = read_config(config, server=True)
        # command line parameters supercede config file parameters
        _vars["Connection"][
            "host"] = args.host if args.host else _vars["Connection"]["host"]
        _vars["Connection"][
            "port"] = args.port if args.port else _vars["Connection"]["port"]
        _vars["KeyAuth"]["hostkey"] = args.hostkey if args.hostkey else _vars[
            "KeyAuth"]["hostkey"]
        _vars["KeyAuth"]["userkey"] = args.userkey if args.userkey else _vars[
            "KeyAuth"]["userkey"]
        _vars["ROOT"]["rootpath"] = args.rootpath if args.rootpath else _vars[
            "ROOT"]["rootpath"]
        _vars["Logging"]["logfile"] = args.logfile if args.logfile else _vars[
            "Logging"]["logfile"]
        _vars["Logging"][
            "loglevel"] = args.loglevel if args.loglevel else _vars["Logging"][
                "loglevel"]
    if not os.path.isdir(_vars["ROOT"]["rootpath"]) or \
       not os.path.isfile(_vars["KeyAuth"]["hostkey"]) or \
       not os.path.isfile(_vars["KeyAuth"]["userkey"]):
        print_vars(_vars)
        print "Invalid server configuration!"
        sys.exit(1)
    if _vars["Logging"]["logfile"] and not os.path.isfile(
            _vars["Logging"]["logfile"]):
        _vars["Logging"]["logfile"] = None
    print_vars(_vars)
    server.run(**get_vars(_vars))
コード例 #2
0
ファイル: migbox.py プロジェクト: bertl4398/MiGBox
def start_server(args, basedir):
    if args.config:
        _vars = read_config(args.config, server=True)
    else:
        # try to read default configuration file at default location
        config = os.path.join(basedir, "config", "server.cfg")
        _vars = read_config(config, server=True)
        # command line parameters supercede config file parameters
        _vars["Connection"]["host"] = args.host if args.host else _vars["Connection"]["host"]
        _vars["Connection"]["port"] = args.port if args.port else _vars["Connection"]["port"]
        _vars["KeyAuth"]["hostkey"] = args.hostkey if args.hostkey else _vars["KeyAuth"]["hostkey"]
        _vars["KeyAuth"]["userkey"] = args.userkey if args.userkey else _vars["KeyAuth"]["userkey"]
        _vars["ROOT"]["rootpath"] = args.rootpath if args.rootpath else _vars["ROOT"]["rootpath"]
        _vars["Logging"]["logfile"] = args.logfile if args.logfile else _vars["Logging"]["logfile"]
        _vars["Logging"]["loglevel"] = args.loglevel if args.loglevel else _vars["Logging"]["loglevel"]
    if not os.path.isdir(_vars["ROOT"]["rootpath"]) or \
       not os.path.isfile(_vars["KeyAuth"]["hostkey"]) or \
       not os.path.isfile(_vars["KeyAuth"]["userkey"]):
        print_vars(_vars)
        print "Invalid server configuration!"
        sys.exit(1)
    if _vars["Logging"]["logfile"] and not os.path.isfile(_vars["Logging"]["logfile"]):
        _vars["Logging"]["logfile"] = None
    print_vars(_vars)
    server.run(**get_vars(_vars))
コード例 #3
0
ファイル: migbox.py プロジェクト: bertl4398/MiGBox
def start_cli(args, basedir):
    if args.config:
        _vars = read_config(args.config)
    else:
        # try to read default configuration file at default location
        config = os.path.join(basedir, "config", "migbox.cfg")
        _vars = read_config(config)
        # command line parameters supercede config file parameters
        _vars["Sync"][
            "source"] = args.source if args.source else _vars["Sync"]["source"]
        _vars["Sync"]["destination"] = args.destination \
                                    if args.destination else _vars["Sync"]["destination"]
        _vars["Connection"]["sftp_host"] = args.host if args.host else _vars[
            "Connection"]["sftp_host"]
        _vars["Connection"]["sftp_port"] = args.port if args.port else _vars[
            "Connection"]["sftp_port"]
        _vars["KeyAuth"]["hostkey"] = args.hostkey if args.hostkey else _vars[
            "KeyAuth"]["hostkey"]
        _vars["KeyAuth"]["userkey"] = args.userkey if args.userkey else _vars[
            "KeyAuth"]["userkey"]
        _vars["Mount"][
            "mountpath"] = args.mountpath if args.mountpath else _vars[
                "Mount"]["mountpath"]
        _vars["Logging"]["logfile"] = args.logfile if args.logfile else _vars[
            "Logging"]["logfile"]
        _vars["Logging"][
            "loglevel"] = args.loglevel if args.loglevel else _vars["Logging"][
                "loglevel"]
    mode = args.mode
    if mode == "local":
        if not os.path.isdir(_vars["Sync"]["source"]) or \
           not os.path.isdir(_vars["Sync"]["destination"]):
            print "Invalid source/destination path!"
            print_vars(_vars)
            sys.exit(1)
    else:
        if not os.path.isdir(_vars["Sync"]["source"]) or \
           not os.path.isdir(_vars["Mount"]["mountpath"]) or \
           not os.path.isfile(_vars["KeyAuth"]["hostkey"]) or \
           not os.path.isfile(_vars["KeyAuth"]["userkey"]):
            print "Invalid paths, check configuration!"
            print_vars(_vars)
            sys.exit(1)
    if _vars["Logging"]["logfile"] and not os.path.isfile(
            _vars["Logging"]["logfile"]):
        _vars["Logging"]["logfile"] = None
    print_vars(_vars)
    cli.run(mode, **get_vars(_vars))
コード例 #4
0
ファイル: ui.py プロジェクト: salsa-dev/MiGBox
    def run(cls, configfile='', logfile='', icons_path=''):
        paramiko_logger = logging.getLogger("paramiko.transport")
        paramiko_logger.addHandler(logging.NullHandler())
        if not icons_path:
            # try to get icons from default location relative to this module
            # ../../icons
            icons_path = os.path.split(
                             os.path.split(
                                 os.path.split(os.path.abspath(__file__))[0])[0])[0]
            icons_path = os.path.join(icons_path, "icons")

        if not configfile:
            # write config in directory relative to this module
            configfile = os.path.join(os.path.split(os.path.abspath(__file__))[0], "migbox.cfg")
        if not logfile:
            # write log in directory relative to this module
            logfile = os.path.join(os.path.split(os.path.abspath(__file__))[0], "sync.log")

        app = QApplication([])
        app.setApplicationName("MiGBox")
        app.setWindowIcon(QIcon(os.path.join(icons_path, "app.png")))
        global _vars
        _vars = read_config(configfile)
        appUi = cls(configfile, logfile, icons_path)
        appUi.show()

        app.exec_()
コード例 #5
0
ファイル: ui.py プロジェクト: bertl4398/MiGBox
    def run(cls, configfile='', logfile='', icons_path=''):
        paramiko_logger = logging.getLogger("paramiko.transport")
        paramiko_logger.addHandler(logging.NullHandler())
        if not icons_path:
            # try to get icons from default location relative to this module
            # ../../icons
            icons_path = os.path.split(
                             os.path.split(
                                 os.path.split(os.path.abspath(__file__))[0])[0])[0]
            icons_path = os.path.join(icons_path, "icons")

        if not configfile:
            # write config in directory relative to this module
            configfile = os.path.join(os.path.split(os.path.abspath(__file__))[0], "migbox.cfg")
        if not logfile:
            # write log in directory relative to this module
            logfile = os.path.join(os.path.split(os.path.abspath(__file__))[0], "sync.log")

        app = QApplication([])
        app.setApplicationName("MiGBox")
        app.setWindowIcon(QIcon(os.path.join(icons_path, "app.png")))
        global _vars
        _vars = read_config(configfile)
        appUi = cls(configfile, logfile, icons_path)
        appUi.show()

        app.exec_()
コード例 #6
0
ファイル: migbox.py プロジェクト: bertl4398/MiGBox
def start_cli(args, basedir):
    if args.config:
        _vars = read_config(args.config)
    else:
         # try to read default configuration file at default location
        config = os.path.join(basedir, "config", "migbox.cfg")
        _vars = read_config(config)
        # command line parameters supercede config file parameters
        _vars["Sync"]["source"] = args.source if args.source else _vars["Sync"]["source"]
        _vars["Sync"]["destination"] = args.destination \
                                    if args.destination else _vars["Sync"]["destination"]
        _vars["Connection"]["sftp_host"] = args.host if args.host else _vars["Connection"]["sftp_host"]
        _vars["Connection"]["sftp_port"] = args.port if args.port else _vars["Connection"]["sftp_port"]
        _vars["KeyAuth"]["hostkey"] = args.hostkey if args.hostkey else _vars["KeyAuth"]["hostkey"]
        _vars["KeyAuth"]["userkey"] = args.userkey if args.userkey else _vars["KeyAuth"]["userkey"]
        _vars["Mount"]["mountpath"] = args.mountpath if args.mountpath else _vars["Mount"]["mountpath"]
        _vars["Logging"]["logfile"] = args.logfile if args.logfile else _vars["Logging"]["logfile"]
        _vars["Logging"]["loglevel"] = args.loglevel if args.loglevel else _vars["Logging"]["loglevel"]
    mode = args.mode
    if mode == "local":
        if not os.path.isdir(_vars["Sync"]["source"]) or \
           not os.path.isdir(_vars["Sync"]["destination"]):
            print "Invalid source/destination path!"
            print_vars(_vars)
            sys.exit(1)
    else:
        if not os.path.isdir(_vars["Sync"]["source"]) or \
           not os.path.isdir(_vars["Mount"]["mountpath"]) or \
           not os.path.isfile(_vars["KeyAuth"]["hostkey"]) or \
           not os.path.isfile(_vars["KeyAuth"]["userkey"]):
            print "Invalid paths, check configuration!"
            print_vars(_vars)
            sys.exit(1)
    if _vars["Logging"]["logfile"] and not os.path.isfile(_vars["Logging"]["logfile"]):
        _vars["Logging"]["logfile"] = None
    print_vars(_vars)
    cli.run(mode, **get_vars(_vars))