Exemplo n.º 1
0
def main():
	print("Web Started!")
	while True:
		starttime = time.time()
		web()
		for i in range (1,30):
			print("sleeping: ", i, "- 30.", end='\r')
			time.sleep(1)
		print()
		print("Total time consumed: ", time.time() - starttime)
Exemplo n.º 2
0
def main():
    arguments = docopt(__doc__, version='PyTach 0.1')
    config.arguments = arguments

    if arguments['--web']:
        web()
    elif arguments['--arduino']:
        arduino(arguments)
    elif arguments['--discover']:
        itach.discover()
    elif arguments['--devices']:
        list_devices()
    elif arguments['--activities']:
        list_activities()
    else:
        activity_device(arguments)
Exemplo n.º 3
0
def main():
    arguments = docopt(__doc__, version='PyTach 0.1')
    config.arguments = arguments

    if arguments['--web']:
        web()
    elif arguments['--arduino']:
        arduino(arguments)
    elif arguments['--discover']:
        itach.discover()
    elif arguments['--devices']:
        list_devices()
    elif arguments['--activities']:
        list_activities()
    else:
        activity_device(arguments)
Exemplo n.º 4
0
    def __init__(self,agent=None,http_proxy=None) :
        self._login = None
        self._passwd = None

        self._agent = agent or CONST.AGENT
        self._web = web(agent=self._agent,http_proxy=http_proxy)
        self._sid = None

        self._token = None
Exemplo n.º 5
0
    def scrapy_slave(self, other_url, mon):
        self.spider = web(35)
        length = self.spider.get_page_length(other_url + str(1))
        print("len={0}".format(length))
        count = 0
        step = 5
        while True:

            self.spider.get_overall_info(other_url, count, count + step, mon)
            self.spider.get_downlink()
            self.update_data()
            self.spider.reset()
            count = count + step
            if count + step > length:
                break
            time.sleep(30)
        self.spider.get_overall_info(other_url, count, length, mon)
        self.spider.get_downlink()
        self.update_data()
        self.spider.reset()
Exemplo n.º 6
0
from InputData import input_data
from calculation import cal
from gui import gui
from web import web

web()
data = input_data()
maxNum, maxDay, minNum, minDay, ave, mid = cal(data)
gui(maxNum, maxDay, minNum, minDay, ave, mid, data)
Exemplo n.º 7
0
def jw():
    root.destroy()
    web()
Exemplo n.º 8
0
Arquivo: server.py Projeto: jledet/mcc
    def server(self):
        # Parse configuration
        conf = config.config(VERSION)

        # Register cleanup function
        atexit.register(self.cleanup)

        # Get logging instance
        self.mcclog = logging.getLogger("self.mcclog")
        self.mcclog.setLevel(logging.DEBUG)
        logformatter = logging.Formatter("[%(levelname)7s] %(asctime)s %(module)s: %(message)s")
        colorformatter = ColorFormatter("[%(levelname)21s] %(asctime)s %(module)s: %(message)s")
        if conf.verbose:
            loglvl = logging.DEBUG
        else:
            loglvl = logging.INFO

        if conf.daemon:
            # Daemonize
            try:
                daemon.daemonize()
            except Exception as e:
                sys.exit(1)
        else:
            # Enable logging to stdout
            streamhandler = logging.StreamHandler()
            if conf.color:
                streamhandler.setFormatter(colorformatter)
            else:
                streamhandler.setFormatter(logformatter)
            streamhandler.setLevel(loglvl)
            self.mcclog.addHandler(streamhandler)

        # Check if logging to file is enabled
        if not conf.logfile == None:
            filehandler = logging.FileHandler(conf.logfile)
            filehandler.setFormatter(logformatter)
            filehandler.setLevel(loglvl)
            self.mcclog.addHandler(filehandler)

        # Start the program
        self.mcclog.info("AAUSAT3 MCC Server {0}".format(VERSION))
        self.mcclog.info("Copyright (c) 2009-2011 Jeppe Ledet-Pedersen <*****@*****.**>")
        uname = os.uname()
        self.mcclog.info("Running on {0} {1} {2}".format(uname[0], uname[2], uname[4]))

        # Print process info
        self.mcclog.info(
            "pid={0}, ppid={1}, pgrp={2}, sid={3}, uid={4}, euid={5}, gid={6}, egid={7}".format(
                os.getpid(),
                os.getppid(),
                os.getpgrp(),
                os.getsid(0),
                os.getuid(),
                os.geteuid(),
                os.getgid(),
                os.getegid(),
            )
        )

        # Test if HP is running the program as root
        if os.geteuid() == 0:
            self.mcclog.warning("Running the MCC as root is both unnecessary and a very bad idea")

        # Validate interface arguments
        if not conf.csp_enable:
            self.mcclog.warning("CSP interface disabled. Replay only mode.")

        # Connect to Database
        if conf.db_type == "postgresql":
            try:
                self.dbconn = database.postgresqlmanager(self.mcclog, conf)
                self.dbconn.test()
            except Exception as e:
                self.mcclog.error(
                    "Failed to start PostgreSQL Database Manager with host={0}, db={1}, user={2} ({3})".format(
                        conf.db_host, conf.db_name, conf.db_user, str(e).replace("\n\t", " ").replace("\n", "")
                    )
                )
                sys.exit(1)
            self.mcclog.info(
                "Started PostgreSQL Database Manager with host={0}, db={1}, user={2}".format(
                    conf.db_host, conf.db_name, conf.db_user
                )
            )
        elif conf.db_type == "mysql":
            try:
                self.dbconn = database.mysqlmanager(self.mcclog, conf)
                self.dbconn.test()
            except Exception as e:
                self.mcclog.error(
                    "Failed to start MySQL Database Manager with host={0}, db={1}, user={2} ({3})".format(
                        conf.db_host, conf.db_name, conf.db_user, str(e).replace("\n\t", " ").replace("\n", "")
                    )
                )
                sys.exit(1)
            self.mcclog.info(
                "Started MySQL database manager with host={0}, db={1}, user={2}".format(
                    conf.db_host, conf.db_name, conf.db_user
                )
            )
        elif conf.db_type == "sqlite":
            try:
                self.dbconn = database.sqlitemanager(self.mcclog, conf)
                self.dbconn.test()
            except Exception as e:
                self.mcclog.error("Failed to start SQLite Database Manager for {0} ({1})".format(conf.db_file, e))
                sys.exit(1)
            self.mcclog.info("Started SQLite database manager for {0}".format(conf.db_file))
        else:
            self.mcclog.error(
                "{0} is not a valid database type. Use either postgresql, mysql or sqlite".format(conf.db_type)
            )
            sys.exit(1)

        # Initialize CSP
        if conf.csp_enable:
            try:
                self.csp = csp.csp(self.mcclog, self.dbconn, self.inq, self.outq, conf)
            except Exception as e:
                self.mcclog.error("Failed to initialize CSP ({0})".format(e))
                sys.exit(1)
            self.mcclog.info("Initialized CSP for address {0}".format(conf.csp_host))

        # Initialize Tracking
        if conf.track_enable:
            try:
                self.tracker = tracker.tracker(self.mcclog, self.outq, conf)
            except Exception as e:
                self.mcclog.error("Failed to initialize Tracker ({0})".format(e))
                sys.exit(1)
            self.mcclog.info("Initialized Tracker")

        # Initialize Web Interface
        if conf.web_enable:
            try:
                self.web = web.web(conf.web_port, conf.web_auth, conf.web_https, conf.web_certfile)
            except Exception as e:
                self.mcclog.error("Failed to initialize Web Interface ({0})".format(e))
                sys.exit(1)
            self.mcclog.info("Initialized Web Interface on port {0}".format(conf.web_port))

        # Initialize Connection Manager
        try:
            self.connman = connmanager.connectionmanager(self.mcclog, self.dbconn, self.connlist, self.outq, conf)
        except Exception as e:
            self.mcclog.error(
                "Failed to initialize Connection Manager on port {0}, {1} ({2})".format(
                    conf.listen_port,
                    "connection limit: {0}".format(conf.max_users if int(conf.max_users) > 0 else "none"),
                    e,
                )
            )
            sys.exit(1)

        self.mcclog.info(
            "Initialized Connection Manager on port {0}, {1}".format(
                conf.listen_port, "connection limit: {0}".format(conf.max_users if int(conf.max_users) > 0 else "none")
            )
        )

        if not conf.use_tls:
            self.mcclog.warning("TLS encryption is disabled! Eve can read your data...")

        self.mcclog.info("Startup sequence completed - Listening for incoming connections")

        # Enter main loop
        rx_packets = 0
        tx_packets = 0
        while True:
            try:
                packet = self.inq.get(True, 30)
            except Queue.Empty:
                pass
            except KeyboardInterrupt:
                print ""
                self.mcclog.info("Closing AAUSAT3 MCC Server")
                sys.exit(0)
            except Exception as e:
                self.mcclog.error("Caught exception ({0})".format(e))
                sys.exit(1)
            else:
                if packet.source == conf.csp_host and packet.sport >= 17:
                    tx_packets += 1
                else:
                    rx_packets += 1
                self.mcclog.debug("Distributing packet: {0}".format(packet.debug()))
                self.mcclog.debug("Packets transmitted: {0}, Packets received: {1}".format(tx_packets, rx_packets))
                # Add packet to packet queues
                for conn in self.connlist:
                    if conn.enabled and conn.authorized:
                        conn.queue.put(packet)
        print "STOPPED unexpect"
Exemplo n.º 9
0
from web import web

url = input('Здравствуй, введи адрес страницы: ')
depth = input('Теперь введи величину глубины поиска: ')

web = web(url, depth)

web.scan()

Exemplo n.º 10
0
 def __call__(self, environ, start_response):
     for rule, func in ROUTE_MAP:
         if rule.match(environ['PATH_INFO']):
             return func(environ, start_response)
     return web(environ, start_response)
Exemplo n.º 11
0
 def __call__(self, environ, start_response):
     for rule, func in ROUTE_MAP:
         if rule.match(environ['PATH_INFO']):
             return func(environ, start_response)
     return web(environ, start_response)