コード例 #1
0
def run():
    global options, old
    args = sys.argv[1:]
    if '-l' in args:  # CVS is an idiot
        i = args.index('-l')
        args = args[i:i + 2] + args
        del args[i + 2:i + 4]
    for arg in args[:]:
        try:
            i = args.index(arg)
            if arg[:2] == '-o' and args[i + 1][0] != '-':
                args[i:i + 2] = []  # Suck on it scp
        except ValueError:
            pass
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError as u:
        print('ERROR: {}'.format(u))
        options.opt_help()
        sys.exit(1)
    if options['log']:
        if options['logfile']:
            if options['logfile'] == '-':
                f = sys.stdout
            else:
                f = open(options['logfile'], 'a+')
        else:
            f = sys.stderr
        realout = sys.stdout
        log.startLogging(f)
        sys.stdout = realout
    else:
        log.discardLogs()
    doConnect()
    fd = sys.stdin.fileno()
    try:
        old = tty.tcgetattr(fd)
    except:
        old = None
    try:
        oldUSR1 = signal.signal(signal.SIGUSR1,
                                lambda *a: reactor.callLater(0, reConnect))
    except:
        oldUSR1 = None
    try:
        reactor.run()
    finally:
        if old:
            tty.tcsetattr(fd, tty.TCSANOW, old)
        if oldUSR1:
            signal.signal(signal.SIGUSR1, oldUSR1)
        if (options['command'] and options['tty']) or not options['notty']:
            signal.signal(signal.SIGWINCH, signal.SIG_DFL)
    if sys.stdout.isatty() and not options['command']:
        print('Connection to {} closed.'.format(options['host']))
    sys.exit(exitStatus)
コード例 #2
0
ファイル: conch.py プロジェクト: BarnetteME1/indeed_scraper
def run():
    global options, old
    args = sys.argv[1:]
    if '-l' in args: # cvs is an idiot
        i = args.index('-l')
        args = args[i:i+2]+args
        del args[i+2:i+4]
    for arg in args[:]:
        try:
            i = args.index(arg)
            if arg[:2] == '-o' and args[i+1][0]!='-':
                args[i:i+2] = [] # suck on it scp
        except ValueError:
            pass
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError as u:
        print('ERROR: %s' % u)
        options.opt_help()
        sys.exit(1)
    if options['log']:
        if options['logfile']:
            if options['logfile'] == '-':
                f = sys.stdout
            else:
                f = file(options['logfile'], 'a+')
        else:
            f = sys.stderr
        realout = sys.stdout
        log.startLogging(f)
        sys.stdout = realout
    else:
        log.discardLogs()
    doConnect()
    fd = sys.stdin.fileno()
    try:
        old = tty.tcgetattr(fd)
    except:
        old = None
    try:
        oldUSR1 = signal.signal(signal.SIGUSR1, lambda *a: reactor.callLater(0, reConnect))
    except:
        oldUSR1 = None
    try:
        reactor.run()
    finally:
        if old:
            tty.tcsetattr(fd, tty.TCSANOW, old)
        if oldUSR1:
            signal.signal(signal.SIGUSR1, oldUSR1)
        if (options['command'] and options['tty']) or not options['notty']:
            signal.signal(signal.SIGWINCH, signal.SIG_DFL)
    if sys.stdout.isatty() and not options['command']:
        print('Connection to %s closed.' % options['host'])
    sys.exit(exitStatus)
コード例 #3
0
ファイル: test_conch.py プロジェクト: AnthonyNystrom/YoGoMee
 def makeAuthClient(self, port, options):
     cmds = (('-p %i -l testuser '
              '--known-hosts kh_test '
              '--user-authentications publickey '
              '--host-key-algorithms ssh-rsa '
              '-a '
              '-K direct '
              '-i dsa_test '
              '127.0.0.1') % port).split()
     options.parseOptions(cmds)
     return default.SSHUserAuthClient(options['user'], options, self.conn)
コード例 #4
0
ファイル: main.py プロジェクト: Nyophyte/proximitymarketing
def start():
    global options, old
    args = sys.argv[1:]

    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError, u:
        print 'ERROR: %s' % u
        options.opt_help()
        sys.exit(1)
コード例 #5
0
 def makeAuthClient(self, port, options):
     cmds = (('-p %i -l testuser '
              '--known-hosts kh_test '
              '--user-authentications publickey '
              '--host-key-algorithms ssh-rsa '
              '-a '
              '-K direct '
              '-i dsa_test '
              '127.0.0.1') % port).split()
     options.parseOptions(cmds)
     return default.SSHUserAuthClient(options['user'], options, self.conn)
コード例 #6
0
def start():
    global options, old
    args = sys.argv[1:]

    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError, u:
        print 'ERROR: %s' % u
        options.opt_help()
        sys.exit(1)
コード例 #7
0
ファイル: cftp.py プロジェクト: MayuraVerma/Kannada
def run():
    #    import hotshot
    #    prof = hotshot.Profile('cftp.prof')
    #    prof.start()
    args = sys.argv[1:]
    if '-l' in args:  # cvs is an idiot
        i = args.index('-l')
        args = args[i:i + 2] + args
        del args[i + 2:i + 4]
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError, u:
        print 'ERROR: %s' % u
        sys.exit(1)
コード例 #8
0
ファイル: cftp.py プロジェクト: AnthonyNystrom/YoGoMee
def run():
#    import hotshot
#    prof = hotshot.Profile('cftp.prof')
#    prof.start()
    args = sys.argv[1:]
    if '-l' in args: # cvs is an idiot
        i = args.index('-l')
        args = args[i:i+2]+args
        del args[i+2:i+4]
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError, u:
        print 'ERROR: %s' % u
        sys.exit(1)
コード例 #9
0
def run():
    args = sys.argv[1:]
    if "-l" in args:  # cvs is an idiot
        i = args.index("-l")
        args = args[i:i + 2] + args
        del args[i + 2:i + 4]
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError as u:
        print("ERROR: %s" % u)
        sys.exit(1)
    if options["log"]:
        realout = sys.stdout
        log.startLogging(sys.stderr)
        sys.stdout = realout
    else:
        log.discardLogs()
    doConnect(options)
    reactor.run()
コード例 #10
0
ファイル: conch.py プロジェクト: ChimmyTee/oh-mainline
def run():
    global options, old
    args = sys.argv[1:]
    if '-l' in args: # cvs is an idiot
        i = args.index('-l')
        args = args[i:i+2]+args
        del args[i+2:i+4]
    for arg in args[:]:
        try:
            i = args.index(arg)
            if arg[:2] == '-o' and args[i+1][0]!='-':
                args[i:i+2] = [] # suck on it scp
        except ValueError:
            pass
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError, u:
        print 'ERROR: %s' % u
        options.opt_help()
        sys.exit(1)
コード例 #11
0
def run():
    global options, old
    args = sys.argv[1:]
    if '-l' in args:  # cvs is an idiot
        i = args.index('-l')
        args = args[i:i + 2] + args
        del args[i + 2:i + 4]
    for arg in args[:]:
        try:
            i = args.index(arg)
            if arg[:2] == '-o' and args[i + 1][0] != '-':
                args[i:i + 2] = []  # suck on it scp
        except ValueError:
            pass
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError, u:
        print 'ERROR: %s' % u
        options.opt_help()
        sys.exit(1)
コード例 #12
0
ファイル: cftp.py プロジェクト: kevinlu310/twisted
def run():
    #    import hotshot
    #    prof = hotshot.Profile('cftp.prof')
    #    prof.start()
    args = sys.argv[1:]
    if '-l' in args:  # cvs is an idiot
        i = args.index('-l')
        args = args[i:i + 2] + args
        del args[i + 2:i + 4]
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError as u:
        print('ERROR: %s' % u)
        sys.exit(1)
    if options['log']:
        realout = sys.stdout
        log.startLogging(sys.stderr)
        sys.stdout = realout
    else:
        log.discardLogs()
    doConnect(options)
    reactor.run()
コード例 #13
0
def run():
#    import hotshot
#    prof = hotshot.Profile('cftp.prof')
#    prof.start()
    args = sys.argv[1:]
    if '-l' in args: # cvs is an idiot
        i = args.index('-l')
        args = args[i:i+2]+args
        del args[i+2:i+4]
    options = ClientOptions()
    try:
        options.parseOptions(args)
    except usage.UsageError as u:
        print('ERROR: %s' % u)
        sys.exit(1)
    if options['log']:
        realout = sys.stdout
        log.startLogging(sys.stderr)
        sys.stdout = realout
    else:
        log.discardLogs()
    doConnect(options)
    reactor.run()