예제 #1
0
    def _tailf(self, path):
        if not self.ctl.upcheck():
            return

        self.ctl.output('==> Press Ctrl-C to exit <==')

        username = self.ctl.options.username
        password = self.ctl.options.password
        try:
            # Python's urllib2 (at least as of Python 2.4.2) isn't up
            # to this task; it doesn't actually implement a proper
            # HTTP/1.1 client that deals with chunked responses (it
            # always sends a Connection: close header).  We use a
            # homegrown client based on asyncore instead.  This makes
            # me sad.
            import http_client
            if self.listener is None:
                listener = http_client.Listener()
            else:
                listener = self.listener # for unit tests
            handler = http_client.HTTPHandler(listener, username, password)
            handler.get(self.ctl.options.serverurl, path)
            asyncore.loop()
        except KeyboardInterrupt:
            handler.close()
            self.ctl.output('')
            return
예제 #2
0
    def _tailf(self, path):
        self.ctl.output('==> Press Ctrl-C to exit <==')

        username = self.ctl.options.username
        password = self.ctl.options.password
        handler = None
        try:
            # Python's urllib2 (at least as of Python 2.4.2) isn't up
            # to this task; it doesn't actually implement a proper
            # HTTP/1.1 client that deals with chunked responses (it
            # always sends a Connection: close header).  We use a
            # homegrown client based on asyncore instead.  This makes
            # me sad.
            import supervisor.http_client as http_client
            if self.listener is None:
                listener = http_client.Listener()
            else:
                listener = self.listener # for unit tests
            handler = http_client.HTTPHandler(listener, username, password)
            handler.get(self.ctl.options.serverurl, path)
            asyncore.loop()
        except KeyboardInterrupt:
            if handler:
                handler.close()
            self.ctl.output('')
            return
예제 #3
0
 def test(port='8021'):
     fs = ftp_server(unix_authorizer(), port=int(port))
     try:
         asyncore.loop()
     except KeyboardInterrupt:
         fs.log_info('FTP server shutting down. (received SIGINT)',
                     'warning')
         # close everything down on SIGINT.
         # of course this should be a cleaner shutdown.
         asyncore.close_all()
예제 #4
0
 def test (port='8021'):
     fs = ftp_server (
             unix_authorizer(),
             port=int(port)
             )
     try:
         asyncore.loop()
     except KeyboardInterrupt:
         fs.log_info('FTP server shutting down. (received SIGINT)', 'warning')
         # close everything down on SIGINT.
         # of course this should be a cleaner shutdown.
         asyncore.close_all()
예제 #5
0
        print 'usage: %s <host> <port> <request-size> <num-requests> <num-connections>\n' % sys.argv[
            0]
    else:
        host = sys.argv[1]

        ip = socket.gethostbyname(host)

        [port, request_size, num_requests,
         num_conns] = map(string.atoi, sys.argv[2:])

        chain = build_request_chain(num_requests, host, request_size)

        t = timer()
        for i in range(num_conns):
            test_client((host, port), chain)
        asyncore.loop()
        total_time = t.end()

        # ok, now do some numbers
        total_bytes = test_client.total_in
        num_trans = num_requests * num_conns
        throughput = float(total_bytes) / total_time
        trans_per_sec = num_trans / total_time

        sys.stderr.write('total time: %.2f\n' % total_time)
        sys.stderr.write('number of transactions: %d\n' % num_trans)
        sys.stderr.write('total bytes sent: %d\n' % total_bytes)
        sys.stderr.write('total throughput (bytes/sec): %.2f\n' % throughput)
        sys.stderr.write('transactions/second: %.2f\n' % trans_per_sec)
        sys.stderr.write('max concurrent connections: %d\n' %
                         test_client.max_concurrent)
예제 #6
0
    import string

    if '--poll' in sys.argv:
        sys.argv.remove ('--poll')
        use_poll=1
    else:
        use_poll=0

    if len(sys.argv) == 1:
        print(('usage: %s\n' \
        '  (as a server) [--poll] -s <ip> <port>\n' \
        '  (as a client) [--poll] -c <ip> <port> <packet-size> <num-packets> <num-connections>\n' % sys.argv[0]))
        sys.exit(0)
    if sys.argv[1] == '-s':
        s = test_server ((sys.argv[2], string.atoi (sys.argv[3])))
        asyncore.loop(use_poll=use_poll)
    elif sys.argv[1] == '-c':
        # create the packet
        packet = string.atoi(sys.argv[4]) * 'B'
        host = sys.argv[2]
        port = string.atoi (sys.argv[3])
        num_packets = string.atoi (sys.argv[5])
        num_conns = string.atoi (sys.argv[6])

        t = timer()
        for i in range (num_conns):
            test_client ((host,port), packet, num_packets)
        asyncore.loop(use_poll=use_poll)
        total_time = t.end()

        # ok, now do some numbers
예제 #7
0
 def run(self):
     self.output_handler.get(self.ctl.options.serverurl,
                             '/logtail/%s/stdout'%self.program)
     self.error_handler.get(self.ctl.options.serverurl,
                            '/logtail/%s/stderr'%self.program)
     asyncore.loop()
예제 #8
0
def start_Server():
#    ftpServ = ftp_server.ftp_server( ftp_server.anon_authorizer( "D:\MyDocuments\MyDownloads"), port=21 )
    ftpServ = ftp_server.ftp_server( Win32Authorizer(), port=21 )
    asyncore.loop()
예제 #9
0
if __name__ == '__main__':
    if '-s' in sys.argv:
        sys.argv.remove('-s')
        print_function('Enter password: '******'')
        password = raw_input()
    else:
        password = None

    if '-e' in sys.argv:
        sys.argv.remove('-e')
        encrypt = 1
    else:
        encrypt = 0

    if len(sys.argv) > 1:
        port = int(sys.argv[1])
    else:
        port = 8023

    if password is not None:
        s = secure_monitor_server(password, '', port)
        if encrypt:
            s.channel_class = secure_encrypted_monitor_channel
            #noinspection PyUnresolvedReferences
            import sapphire
            s.cipher = sapphire
    else:
        s = monitor_server('', port)

    asyncore.loop(use_poll=1)
예제 #10
0
if __name__ == '__main__':
    if '-s' in sys.argv:
        sys.argv.remove ('-s')
        print_function('Enter password: '******'')
        password = raw_input()
    else:
        password = None

    if '-e' in sys.argv:
        sys.argv.remove ('-e')
        encrypt = 1
    else:
        encrypt = 0

    if len(sys.argv) > 1:
        port = int(sys.argv[1])
    else:
        port = 8023

    if password is not None:
        s = secure_monitor_server (password, '', port)
        if encrypt:
            s.channel_class = secure_encrypted_monitor_channel
            #noinspection PyUnresolvedReferences
            import sapphire
            s.cipher = sapphire
    else:
        s = monitor_server ('', port)

    asyncore.loop(use_poll=1)
예제 #11
0
 def run(self):
     self.output_handler.get(self.ctl.options.serverurl, "/logtail/%s/stdout" % self.program)
     self.error_handler.get(self.ctl.options.serverurl, "/logtail/%s/stderr" % self.program)
     asyncore.loop()
예제 #12
0
    import string

    if '--poll' in sys.argv:
        sys.argv.remove('--poll')
        use_poll = 1
    else:
        use_poll = 0

    if len(sys.argv) == 1:
        print(('usage: %s\n' \
        '  (as a server) [--poll] -s <ip> <port>\n' \
        '  (as a client) [--poll] -c <ip> <port> <packet-size> <num-packets> <num-connections>\n' % sys.argv[0]))
        sys.exit(0)
    if sys.argv[1] == '-s':
        s = test_server((sys.argv[2], string.atoi(sys.argv[3])))
        asyncore.loop(use_poll=use_poll)
    elif sys.argv[1] == '-c':
        # create the packet
        packet = string.atoi(sys.argv[4]) * 'B'
        host = sys.argv[2]
        port = string.atoi(sys.argv[3])
        num_packets = string.atoi(sys.argv[5])
        num_conns = string.atoi(sys.argv[6])

        t = timer()
        for i in range(num_conns):
            test_client((host, port), packet, num_packets)
        asyncore.loop(use_poll=use_poll)
        total_time = t.end()

        # ok, now do some numbers
예제 #13
0
 def profile_loop ():
     try:
         asyncore.loop()
     except KeyboardInterrupt:
         pass
예제 #14
0
 def run(self): # pragma: no cover
     self.output_handler.get(self.ctl.options.serverurl,
                             '/logtail/%s/stdout'%self.program)
     self.error_handler.get(self.ctl.options.serverurl,
                            '/logtail/%s/stderr'%self.program)
     asyncore.loop()
예제 #15
0
 def profile_loop():
     try:
         asyncore.loop()
     except KeyboardInterrupt:
         pass
예제 #16
0
        print 'usage: %s <host> <port> <request-size> <num-requests> <num-connections>\n' % sys.argv[0]
    else:
        host = sys.argv[1]

        ip = socket.gethostbyname (host)

        [port, request_size, num_requests, num_conns] = map (
                string.atoi, sys.argv[2:]
                )

        chain = build_request_chain (num_requests, host, request_size)

        t = timer()
        for i in range (num_conns):
            test_client ((host,port), chain)
        asyncore.loop()
        total_time = t.end()

        # ok, now do some numbers
        total_bytes = test_client.total_in
        num_trans = num_requests * num_conns
        throughput = float (total_bytes) / total_time
        trans_per_sec = num_trans / total_time

        sys.stderr.write ('total time: %.2f\n' % total_time)
        sys.stderr.write ('number of transactions: %d\n' % num_trans)
        sys.stderr.write ('total bytes sent: %d\n' % total_bytes)
        sys.stderr.write ('total throughput (bytes/sec): %.2f\n' % throughput)
        sys.stderr.write ('transactions/second: %.2f\n' % trans_per_sec)
        sys.stderr.write ('max concurrent connections: %d\n' % test_client.max_concurrent)
예제 #17
0
def start_Server():
    #    ftpServ = ftp_server.ftp_server( ftp_server.anon_authorizer( "D:\MyDocuments\MyDownloads"), port=21 )
    ftpServ = ftp_server.ftp_server(Win32Authorizer(), port=21)
    asyncore.loop()