Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
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))
Ejemplo n.º 3
0
 def run(self):
     mode = "remote" if self.sftp else "local"
     try:
         syncd.run(mode, username=_otp_user, password=_otp_pass,
                   event=self.event, **get_vars(_vars))
     except Exception as e:
         self.emit(SIGNAL("threadError(QString)"), QString(e.message))
Ejemplo n.º 4
0
 def run(self):
     settings = get_vars(_vars)
     try:
         client = SFTPClient.connect(settings["sftp_host"], int(settings["sftp_port"]),
                                     settings["hostkey"], settings["userkey"],
                                     username=_otp_user, password=_otp_pass)
         client.onetimepass()
     except Exception as e:
         self.emit(SIGNAL("otpError(QString)"), QString(e.message))
Ejemplo n.º 5
0
 def run(self):
     settings = get_vars(_vars)
     try:
         key = paramiko.RSAKey.from_private_key_file(_vars["KeyAuth"]["userkey"])
     except paramiko.PasswordRequiredException:
         dialog = _KeyPassUi(self)
         dialog.exec_()
     try:
         client = SFTPClient.connect(settings["sftp_host"], int(settings["sftp_port"]),
                                     settings["hostkey"], settings["userkey"], _key_pass,
                                     username=_otp_user, password=_otp_pass)
         client.onetimepass()
     except Exception as e:
         self.emit(SIGNAL("otpError(QString)"), QString(e.message))
Ejemplo n.º 6
0
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))
Ejemplo n.º 7
0
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))
Ejemplo n.º 8
0
    def run(self):
        mode = "remote" if self.sftp else "local"
#        try:
        syncd.run(mode, username=_otp_user, password=_otp_pass, keypass=_key_pass,
                      stopsync=self.event, **get_vars(_vars))