예제 #1
0
def main():

    myWebServer = WebServer.WebServer(8082)
    myWebServer.start()
    myWebServer = WebServer.WebServer(8081)
    myWebServer.start()

    pass
예제 #2
0
def register_user(username, password):
    """
    Register the user into the database
    :param username: string
    :param password: string
    """
    error = None
    with WebServer.flask_app_context():
        db = get_db()

        if not username:
            error = 'Username is required.'
        elif not password:
            error = 'Password is required.'
        elif db.execute('SELECT id FROM users WHERE username = ?',
                        (username, )).fetchone() is not None:
            error = 'User {0} is already registered.'.format(username)

        if error is None:
            # the name is available, store it in the database and go to
            # the login page
            db.execute('INSERT INTO users (username, password) VALUES (?, ?)',
                       (username, generate_password_hash(password)))
            db.commit()
    return error
예제 #3
0
    def on_apply_settings(self,evt):
        self.BtnApply.Disable()
        self.Update()
        if(self.wsRunning == False):
            
            self.settings.setWebServer(self.TxtbxTMWebServer.GetValue())
            self.settings.setPort(self.TxtbxPort.GetValue())
            self.settings.setUploadDir(self.TxtbxUploadDir.GetValue())
            self.settings.setTMPassword(self.TxtbxTMPassword.GetValue())
            try:
                self.ws = WebServer(self.settings)
                self.wsThread = threading.Thread(target=self.ws.start)
                self.wsThread.start()
                
                self.BtnRefetch.Enable()

                self.BtnApply.SetLabel("Stop")
                self.TxtbxTMWebServer.Disable()
                self.TxtbxPort.Disable()
                self.TxtbxUploadDir.Disable()
                self.TxtbxTMPassword.Disable()
                self.wsRunning = True
            except Exception, e:
                self.wsRunning = False
                self.BtnApply.SetLabel("Start")
                self.TxtbxTMWebServer.Enable()
                self.TxtbxPort.Enable()
                self.TxtbxUploadDir.Enable()
                self.TxtbxTMPassword.Enable()
예제 #4
0
    def start(self):
        self.__logger.info("Starting application")

        WebServer.start(
            self.__get_latest_frame,
            self.__get_latest_usage_rate,
            self.__get_meter_reading)

        self.__meter.start_taking_regular_measurements(
            self.__config.meter_measurement_interval_ms,
            self.__get_latest_dial_position
        )

        # self.start_debug_data_collecting_thread()

        self.__logger.info("Starting frame processing")
        while True:
            frame = self.__frame_source.get_next_frame()
            (dial_position, debug_frame) = self.__frame_processor.process_frame_for_dial_position(frame)
            self.__latest_dial_position = dial_position
            self.__latest_frame = debug_frame
예제 #5
0
	def __init__(self, name):
		super(Node, self).__init__()
		self.name = name
		self.mempool = set([])
		self.blockchain = [Block.Block(num_ = 0, data_ = ["Genesis Block"], hashb_ = "None", hashp_ = "None", transactionCount = 1)]
		self.difficulty = 4 
		self.nodeServer = NodeServer.NodeServer(name, 4242, self)
		self.webServer = WebServer.WebServer(name, 4254, self)
		self.client = Client.Client(name)
		self.miner = Miner.Miner(self, self.difficulty)
		self.consenter = Consenter.Consenter(self, self.difficulty)
		self.hosts = set([])
		self.webHosts = set([])
예제 #6
0
    def run():

        # CONFIGURE WEB SERVER
        web = WebServer(login=API.login, jwt_expire=os.getenv('JWT_EXPIRE'))

        # ADD YOUR ROUTES HERE
        web.add({ "url": "/public", "callback": API.api_public, "methods": ['GET'] })
        web.add({ "url": "/secure", "callback": API.api_secure, "methods": ['GET'] })

        # RUN APP
        web.run(port=os.getenv('PORT') or 8080, debug=(os.getenv('MODE') != 'production'))
예제 #7
0
	def startTrading(self):
		#prices = []
		currentMovingAverage = 0;
		startTime = False
		endTime = False
		historicalData = False
		tradePlaced = False
		typeOfTrade = False
		dataDate = ""
		orderNumber = ""

		market_fees = 0.15          # coinbase per-transaction fee in dollars
		min_profit_margin = 2.0     # minimum price increase before we sell out
	
		MACD = 0


		if webserver:
			try:
				WebServer.initialize_web_server()
			except Exception as e:
				raise e
			finally:
				WebServer.stop_web_server()
	
		
		idloop = 0

		#self.sync_buys_sells_operations()


		while True:
			try:
				if idloop < lengthOfMA:
					idloop = idloop + 1

				if strategy == "RSI": 
					self.classic_strategy()
				elif strategy == "MACD":
					self.MACD_Strategy()
				elif strategy == "combined":
					self.MACD_RSI_Strategy(idloop)
				time.sleep(int(period))

			except KeyboardInterrupt:
				print("Bye")
				if webserver:
					WebServer.stop_web_server()
				sys.exit()
    def initialize(self):
        """
        Starts all modules
        Exit if the service is alreayd running or if the config file is missing
        """
        starttime = time.time()
        if self.isrunning():
            sys.stdout.write(" (server is already running)")
            sys.exit(1)

        self.daemonize()
        try:
            # Initialize
            self.info("Starting up server...")
            self.trace("** System encoding (in): %s" % sys.stdin.encoding)
            self.trace("** System encoding (out): %s" % sys.stdout.encoding)
            self.info("Settings, Logger and CLI ready")

            DbManager.initialize()
            DbManager.instance().isUp()
            self.info("Database manager ready")
            WebServer.isUp()
            self.info("Web server ready")

            # Initialize the core
            Context.initialize()
            Context.instance().setStartTime()
            Context.instance().setMysqlVersion()
            Context.instance().setApacheVersion()
            Context.instance().setPhpVersion()
            Context.instance().synchronizeDynamicCfg()
            if Settings.getInt('Server', 'use-ifconfig'):
                Context.instance().listEths()
            else:
                Context.instance().listEthsNew()
            Context.instance().listRoutes()
            self.info("Context ready")
            self.deploy()
            self.info("Symbolic links created")
            ProjectsManager.initialize(context=Context.instance())
            self.info("Projects Manager ready")
            UsersManager.initialize(context=Context.instance())
            self.info("Users Manager ready")
            StatsManager.initialize()
            self.info("Stats Manager ready")

            TaskManager.initialize(statsmgr=StatsManager.instance(),
                                   context=Context)
            self.info("Task Manager ready")

            # Initialize all repositories
            RepoTests.initialize(context=Context.instance(),
                                 taskmgr=TaskManager.instance())
            self.info("Repo manager for tests ready")
            RepoArchives.initialize(context=Context.instance(),
                                    taskmgr=TaskManager.instance())
            self.info("Repo manager for archives ready")
            RepoAdapters.initialize(context=Context.instance(),
                                    taskmgr=TaskManager.instance())
            StorageDataAdapters.initialize(context=Context.instance())
            self.info("Adapters Manager and Storage Data ready")
            RepoLibraries.initialize(context=Context.instance(),
                                     taskmgr=TaskManager.instance())
            self.info("Libraries adapters manager ready")
            RepoPublic.initialize()
            self.info("Repo manager for public area is ready")

            HelperManager.initialize()
            self.info("Helper manager ready")

            ProbesManager.initialize(context=Context.instance())
            self.info("Probes Manager ready")

            AgentsManager.initialize(context=Context.instance())
            self.info("Agents Manager ready")

            ToolboxManager.initialize()
            self.info("Toolbox Manager ready")

            # Initialize all interfaces
            self.info("Starting ESI on %s:%s" % (Settings.get(
                'Bind', 'ip-esi'), Settings.getInt('Bind', 'port-esi')))
            EventServerInterface.initialize(
                listeningAddress=(Settings.get('Bind', 'ip-esi'),
                                  Settings.getInt('Bind', 'port-esi')),
                sslSupport=Settings.getInt('Client_Channel', 'channel-ssl'),
                wsSupport=Settings.getInt('Client_Channel',
                                          'channel-websocket-support'),
                context=Context.instance())
            self.info("Starting TSI on %s:%s" % (Settings.get(
                'Bind', 'ip-tsi'), Settings.getInt('Bind', 'port-tsi')))
            TestServerInterface.initialize(listeningAddress=(Settings.get(
                'Bind', 'ip-tsi'), Settings.getInt('Bind', 'port-tsi')),
                                           statsmgr=StatsManager.instance(),
                                           context=Context.instance())
            self.info("Starting RSU on %s:%s" % (Settings.get(
                'Bind', 'ip-rsi'), Settings.getInt('Bind', 'port-rsi')))
            RestServerInterface.initialize(
                listeningAddress=(Settings.get('Bind', 'ip-rsi'),
                                  Settings.getInt('Bind', 'port-rsi')))
            self.info("Starting PSI on %s:%s" % (Settings.get(
                'Bind', 'ip-psi'), Settings.getInt('Bind', 'port-psi')))
            ProbeServerInterface.initialize(
                listeningAddress=(Settings.get('Bind', 'ip-psi'),
                                  Settings.getInt('Bind', 'port-psi')),
                sslSupport=Settings.getInt('Probe_Channel', 'channel-ssl'),
                wsSupport=Settings.getInt('Probe_Channel',
                                          'channel-websocket-support'),
                context=Context.instance())
            self.info("Starting ASI on %s:%s" % (Settings.get(
                'Bind', 'ip-asi'), Settings.getInt('Bind', 'port-asi')))
            AgentServerInterface.initialize(
                listeningAddress=(Settings.get('Bind', 'ip-asi'),
                                  Settings.getInt('Bind', 'port-asi')),
                sslSupport=Settings.getInt('Agent_Channel', 'channel-ssl'),
                wsSupport=Settings.getInt('Agent_Channel',
                                          'channel-websocket-support'),
                tsi=TestServerInterface.instance(),
                context=Context.instance())

            # Start on modules
            RestServerInterface.instance().start()
            self.info("RSI is listening on tcp://%s:%s" % (Settings.get(
                'Bind', 'ip-rsi'), Settings.get('Bind', 'port-rsi')))
            EventServerInterface.instance().startSA()
            self.info("ESI is listening on tcp://%s:%s" % (Settings.get(
                'Bind', 'ip-esi'), Settings.get('Bind', 'port-esi')))
            TestServerInterface.instance().startSA()
            self.info("TSI is listening on tcp://%s:%s" % (Settings.get(
                'Bind', 'ip-tsi'), Settings.get('Bind', 'port-tsi')))
            ProbeServerInterface.instance().startSA()
            self.info("PSI is listening on tcp://%s:%s" % (Settings.get(
                'Bind', 'ip-psi'), Settings.get('Bind', 'port-psi')))
            AgentServerInterface.instance().startSA()
            self.info("ASI is listening on tcp://%s:%s" % (Settings.get(
                'Bind', 'ip-asi'), Settings.get('Bind', 'port-asi')))

            # Now start the scheduler and reload tasks
            taskReloaded = TaskManager.instance().loadBackups()
            if taskReloaded is None:
                self.info("Reload tasks disabled")
            elif taskReloaded:
                self.info("Tasks reloaded")
            else:
                self.error("Failed to reload tasks")

            self.info("Schedule automatic backups...")
            if Settings.getInt('Backups', 'tests'):
                RepoAdapters.instance().scheduleBackup()
                self.info("Backup tests scheduled")
            else:
                self.info("Backup tests disabled")

            if Settings.getInt('Backups', 'adapters'):
                RepoTests.instance().scheduleBackup()
                self.info("Backup adapters scheduled")
            else:
                self.info("Backup adapters disabled")

            if Settings.getInt('Backups', 'libraries'):
                RepoLibraries.instance().scheduleBackup()
                self.info("Backup libraries scheduled")
            else:
                self.info("Backup libraries disabled")

            if Settings.getInt('Backups', 'archives'):
                RepoArchives.instance().scheduleBackup()
                self.info("Backup archives scheduled")
            else:
                self.info("Backup archives disabled")

        except Exception as e:
            self.error("Unable to start server: %s" % str(e))
            self.cleanup()
            sys.exit(3)
        stoptime = time.time()
        self.info("%s successfully started (in %s sec.)" %
                  (Settings.get('Server', 'name'), int(stoptime - starttime)))
        self.setrunning()
        self.run()
예제 #9
0
def main():
    server = WebServer.webServer()
    server.init('0.0.0.0', 8080)
    server.run()
예제 #10
0
파일: run.py 프로젝트: ochzhen/webserver
def make_server(server_address, app_handler):
    web_server = WebServer.WebServer(server_address)
    web_server.set_app_handler(app_handler)
    return web_server
예제 #11
0
def index():
    routes = WebServer.get_routes()
    return WebServer.render('index.html', {
        'routes': routes
    })
예제 #12
0
import time

import GameServer
import WebServer

if __name__ == "__main__":
    go = True
    game = GameServer.Game()
    game.start()
    web = WebServer.Web(game)
    web.start()
    while go:
        try:
            d = raw_input("(Q)uit, (W)ebServer, (G)ameServer\n")
        except EOFError:
            continue
        except KeyboardInterrupt:
            print "Keyboard interrupt. Exiting..."
            go = False
            break
        if "Q" in d.upper():
            print "Quiting"
            go = False
            break
        if "W" in d.upper():
            print "Reloading Web Server"
            web.go = False
            reload(WebServer)
            web = WebServer.Web(game)
            web.start()
        if "G" in d.upper():
예제 #13
0
 def web_server_start(launch_control):
     WebServer.WebServer(launch_control).start()
예제 #14
0
import pyautogui
import WebServer

# pyautogui.click(118, 185)
webserver = WebServer.Webserver()
webserver.start()
예제 #15
0
import WebServer

if __name__ == "__main__":
    WebServer.setup()
    WebServer.run()
예제 #16
0
tracts = ['AF', 'CST_M1', 'IFOF', 'ILF', 'UF'];
targetTubeCount = 100

for tract in tracts:
    tubeNodes = slicer.util.getNodes('vtkMRMLFiberBundleTubeDisplayNode*', useLists=True).values()
    for tubeNode in tubeNodes[0]:
        tubeNode.SetVisibility(0)
    node = slicer.util.getNode(tract+'*')
    clusters = vtk.vtkCollection()
    node.GetChildrenDisplayableNodes(clusters)
    for clusterIndex in range(clusters.GetNumberOfItems()):
        cluster = clusters.GetItemAsObject(clusterIndex)
        tubeNode = cluster.GetNthDisplayNode(1)
        tubeNode.SetVisibility(1)
    slicer.util.delayDisplay(tract, 100)
    exporter = WebServer.glTFExporter(slicer.mrmlScene)
    exporter.targetTubeCount = targetTubeCount
    outPath = os.path.join(exportDirectory, tract+".gltf")
    fp = open(outPath, 'w');
    fp.write(exporter.export())
    fp.close()

slicer.util.delayDisplay("done")


# You need to run this in a version of Slicer with SlicerDMRI installed.
#
# Also, use this work-in-progress scripted module web server
# https://github.com/pieper/SlicerWeb/blob/master/WebServer/WebServer.py
#
# then start Slicer like this:
#SEE /etc/rc.local FOR BOOTUP COMMANDS

from Measure_and_File import *
from WebServer import *
import threading

web = WebServer()
board_boy = Measurer_and_Filer()


class myThread(threading.Thread):
    def __init__(self, threadID):  #, name):
        threading.Thread.__init__(self)
        self.threadID = threadID
        #self.name = name
    def run(self):
        try:
            if self.threadID == 1:
                print("Starting measuring_and_filing")
                board_boy.measure_and_file()
            elif self.threadID == 2:
                print("Starting web_serving")
                web.serve()
        except:
            print("Error: unable to start threads")


# Create new threads
measuring_and_filing = myThread(1)
web_serving = myThread(2)
예제 #18
0
파일: main.py 프로젝트: Fedma123/LoomoDemo
    return encoded_png_canny.tobytes()
    #return "OK"


def process_front_image(img):
    raw_image_bytes = np.frombuffer(img, dtype=np.uint8)
    image = cv2.imdecode(raw_image_bytes, cv2.IMREAD_COLOR)
    canny_image = cv2.Canny(image, 30, 120)
    retval, encoded_png_canny = cv2.imencode(".png", canny_image)
    return encoded_png_canny.tobytes()


if __name__ == '__main__':
    ip_address = '0.0.0.0'

    web_server_port = 49000
    udp_server_port = 49001

    head_frame_queue = queue.Queue()
    front_frame_queue = queue.Queue()

    udp_server = UdpServer.UdpServer(ip_address, udp_server_port,
                                     process_head_image)

    print("Server IP: %s" % ip_address)
    udp_server.start()
    print("UDP port: %d" % udp_server_port)
    print("HTTP port: %d" % web_server_port)
    WebServer.start(ip_address, web_server_port, process_head_image,
                    process_front_image)
 def test_db_query(self):
     try:
         WebServer.get_news(10)
         pass
     except:
         self.fail("Database query failed!")
 def test_flask(self):
     try:
         WebServer.hello()
         pass
     except:
         self.fail("Flask failed!")
예제 #21
0
import WebServer

WebServer.start_WebServer()