当前位置: 首页>>代码示例>>Python>>正文


Python Server.Server类代码示例

本文整理汇总了Python中Server.Server的典型用法代码示例。如果您正苦于以下问题:Python Server类的具体用法?Python Server怎么用?Python Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PiggyNetwork

class PiggyNetwork():

	host = '127.0.0.1'
	base_port = 50000
	base_data_path = "/primary_data.txt"
	base_backup_path = "/backup_data.txt"
	# Defining the workload per server. In this case clients with last names A-M are processed by server 1 #
	# and clients with last names N-Z are processed by server 2 #
	total_workload = list(string.ascii_uppercase)

	# Initialize our Network with two servers, with divided workloads, and their relevant data paths. Each server is then #
	# added to the other's detectable network                                                                             #
	def __init__(self):
		self.server1 = Server(self.base_port, self.total_workload[:14], "server1" + self.base_data_path, "server1" + self.base_backup_path)
		self.server2 = Server(self.base_port + 1, self.total_workload[14:], "server2" + self.base_data_path, "server2" + self.base_backup_path)
		self.server1.add_server_to_network(self.server2)
		self.server2.add_server_to_network(self.server1)

	# Getters #
	def get_server1(self):
		return self.server1

	def get_server2(self):
		return self.server2
	# End Getters #

	# Multi-Threaded Functionality #
	def boot_server(self, server):
		server.listen()

	def initialize(self):
		thread1 = threading.Thread(target=self.boot_server, args=(self.server1,))
		thread2 = threading.Thread(target=self.boot_server, args=(self.server2,))
		thread1.start()
		thread2.start()
开发者ID:arjungupta291,项目名称:AJ-Code-Samples,代码行数:35,代码来源:PiggyNetwork.py

示例2: server

    def server(self, dist, target, upgrade_from_path=None, start=False):

        if upgrade_from_path is not None:
            raise Exception("***DEPRECATED*** Please use \"xl-helper upgrade server\"")

        source = dist.path if isinstance(dist, LocalServerDist) else self.cache.get(dist)

        ZipFile(source, 'r').extractall(target)

        # Copy available plugins
        server_dir = os.path.join(target, '.'.join(dist.get_filename().split('.')[:-1]))

        print "Server has been installed to %s" % server_dir

        for root, dirs, files in os.walk(os.path.join(server_dir, 'available-plugins')):
            for file_ in files:
                print "Copying available plugin %s" % file_
                if file_.endswith('.jar'):
                    shutil.copy(os.path.join(root, file_), os.path.join(server_dir, 'plugins', file_))

        proper_license = self.license_location if (dist.version == 'SNAPSHOT' or int(dist.version[0]) >= 4) else self.license_location_3x

        print "Copying license from %s" % proper_license
        shutil.copy(proper_license, os.path.join(server_dir, 'conf', 'deployit-license.lic'))

        for dirpath, d, file_names in os.walk(target):
            for filename in file_names:
                if filename.endswith(".sh"):
                    os.chmod(dirpath + '/' + filename, 0750)

        if start:
            Server.from_config(config=self.config, home=server_dir).run()

        return server_dir
开发者ID:xebialabs-community,项目名称:xld-install-helper,代码行数:34,代码来源:Installer.py

示例3: connect_to_server

    def connect_to_server(self, hostname, port):
        """Handle connection to desired server

        Handles checking of certificate.

        Return Server instance."""

        self.logger.info("Connecting to %s:%s" % (hostname, port))
        try:
            server = Server(hostname, port)
        except Exception as e:
            self.logger.error("Error connecting to %s:%s: %s" % (hostname, port, e))
            raise
        self.logger.debug("Server subject is %s" % server.subject().as_text())

        self.logger.info("Checking certificate with Perspectives")
        try:
            fingerprint = server.get_fingerprint()
            service = Service(hostname, port)
            self.checker.check_seen_fingerprint(service, fingerprint)
        except PerspectivesException as e:
            self.logger.error("Perspectives check failed: %s" % str(e))
            raise

        self.logger.debug("Connection to server established")
        return server
开发者ID:danwent,项目名称:PerProxy,代码行数:26,代码来源:PerProxy.py

示例4: __init__

    def __init__(self, gui, name, parent=None):
        Server.__init__(self, gui, name)
        ns = Pyro.naming.NameServerLocator().getNS()
        self.game = Pyro.core.getProxyForURI(ns.resolve('jeopardy'))
        #    'PYRONAME://' + 'jeopardy')
        self.running = False

        self.name = name
开发者ID:GunioRobot,项目名称:Jeopy,代码行数:8,代码来源:PlayerServer.py

示例5: __init__

	def __init__(self, config, buffSize=1024):
		Server.__init__(self, config["eventServer"]["ipAddress"], 
			config["eventServer"]["port"], buffSize)
		self.dbConfig = config["dbSettings"]
		self.running = True
		self.mediaDir = "media/"
		if not os.path.isdir(self.mediaDir):
			os.makedirs(self.mediaDir)

		print("Event Consumer Server started...")
开发者ID:BallisticBuddha,项目名称:HomeSecurityProject,代码行数:10,代码来源:EventConsumer.py

示例6: testElectionTimeout

def testElectionTimeout():
    s1 = Server()
    s2 = Server()
    s3 = Server()
    
    s1.setNeighbors([s2, s3])
    s2.setNeighbors([s1, s3])
    s3.setNeighbors([s1, s2])
    
    t1 = Thread(target=s1.electionTimeout)
    t1.start()
    time.sleep(5)
    t2 = Thread(target=s2.electionTimeout)
    t2.start()
    t3 = Thread(target=s3.electionTimeout)
    t3.start()
    
    # Add to the leaders log a command no none else has
    s1.clusterLeader.log.append(("test", 1, False, 0))
    
    # Add a state machine no one else has
    s1.clusterLeader.stateMachine[1] = "test"

    time.sleep(5)
    assertion(s1.state == ServerState.leader, "Server should be the leader.")
    assertion(s2.state == ServerState.follower, "Server should be the follower.")
    assertion(s3.state == ServerState.follower, "Server should be the follower.")
    
    assertion(len(s1.clusterLeader.log) == 2, "Server has the right size log.")
    assertion(s1.log == s2.log, "Server has the right log.")
    assertion(s3.log == s2.log, "Server has the right log.")
    assertion(s2.log == s3.log, "Server has the right log.")
    
    assertion(len(s1.stateMachine) == 1, "Server has the right size state machine.")
    assertion(s1.stateMachine[1] == s2.stateMachine[1], "Server has the right state machine")
开发者ID:gddmkr42171822,项目名称:csci5673,代码行数:35,代码来源:ServerTest.py

示例7: main

def main():
    signal.signal(signal.SIGTERM, handler)
    signal.signal(signal.SIGINT, handler)
    server = Server()
    server.start()
    while(exit_flag == 0):
        time.sleep(1)

    print 'Exiting on signal %d, waiting for all threads to finish...' % (exit_flag)
    sys.stdout.flush()
    server.stop()
    print 'done.\n'
开发者ID:syoubin,项目名称:aircraft,代码行数:12,代码来源:Main.py

示例8: __init__

    def __init__(self, host, port):
        """create a XML-RPC server

Takes two initial inputs:
    host  -- hostname of XML-RPC server host
    port  -- port number for server requests
        """
        Server.__init__(self)
        SimpleXMLRPCDispatcher.__init__(self, allow_none=False, encoding=None)

        self._installSocket(host, port)
        self._activeProcesses = {}  # { fd : pid }
开发者ID:haojianggod,项目名称:jd_etl_task,代码行数:12,代码来源:XMLRPCServer.py

示例9: __init__

    def __init__(self,
            stats = None,
            render = None) :
        self.waiting = PriorityQueue()
        self.server = Server()
        self.active = None
        self.events = EventList()
        self.clock = 0
        self.tasks = []
        self.until = 0

        # Statistics
        if stats is not None:
            self.stats = True
            self.stats_file = open(stats, "wb")
            self.stats_writer = csv.writer(self.stats_file, delimiter='|', lineterminator='\n')
            self.write_headers()
        else:
            self.stats = False

        # Rendering
        if render is not None:
            self.render = True
            self.render_file = render
            self.render_data = dict()
        else:
            self.render = False
开发者ID:markusian,项目名称:hybrid-scheduling,代码行数:27,代码来源:Simulator.py

示例10: __init__

 def __init__(self, parent=None):
   #Instance variables
   self.chatLines = []
   self.consoleLines = []
   self.lastServerLine = 'first run'
   self.onlineDict = {}
   self.pluginsDict = {} 
   
   #Initialize a QTimer to run background updates (online players, status, new chat messages, etc)
   self.repeatingTimer = QtCore.QTimer()
   self.singleTimer = QtCore.QTimer() #Not used...
   
   self.s=Server()
   QtGui.QWidget.__init__(self, parent)
   self.ui = Ui_MainWindow()
   self.ui.setupUi(self)
   self.initUI()
   
   self.startRepeatingTimer()
   self.findPlugins() #Find the currently installed plugins by searching the plugin folder
   
   #Set the start/stop button text
   if self.s.status():
     self.ui.pushButtonStopStart.setText('Stop Server')
   else:
     self.ui.pushButtonStopStart.setText('Start Server')
开发者ID:doctoboggan,项目名称:blankkit,代码行数:26,代码来源:main.py

示例11: getModes

	def getModes(self, modes, params=[]):
		modedir="+"
		r=[]
		param_idx=0
		svr=Server.getLinkedServer()
		for modechar in modes:
			if(modechar in ("+", "-")):
				modedir=modechar
				continue
			#if this line makes it crash again, it's Unreal's fault -- svr.chanmodes contains *all* of the modes that it specified in PROTOCTL!
			#which, btw, does not include q, a, o, h, or v - no wonder >.>
			#print svr.chanmodes
			#print svr
			if(modechar in ("q", "a", "o", "h", "v")):
				#r[modeID]=params[param_idx]
				r.append([modedir, modechar, params[param_idx]])
				param_idx+=1
			elif(svr.chanmodes[modechar]=="boolean"):
				#r[modeID]=True
				r.append([modedir, modechar, True])
			elif(modedir=="+" or svr.chanmodes[modechar]=="paramrequired"):
				#r[modeID]=params[param_idx]
				r.append([modedir, modechar, params[param_idx]])
				params_idx+=1
		return r
开发者ID:BasementCat,项目名称:ffservices,代码行数:25,代码来源:Channel.py

示例12: __init__

    def __init__(self):
        print("SpinOS 0.2")
        print("Group 5 IDP 2014 NHL")
        print("Default string encoding : " + str(sys.getdefaultencoding()).upper())
        SpinOS.logger = Logger(Logger.SENSOR_VALUES)
        print("Logger level : " + SpinOS.logger.get_loglevel_string())

        GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
        GPIO.setup(11, GPIO.OUT)
        GPIO.setwarnings(False)

        SpinOS.play_sound(2)
        #logger aanmaken
        self.movementHandler = MovementHandler()

        #server maken op poort 15, omdat ie vrij is
        self.server = Server(15, SpinOS.logger)
        #server starten
        self.server.startServer()
        #server aan logger geven
        SpinOS.logger.set_server(self.server)

        #running op true zetten
        self.running = True
        #mode op manual zetten
        self.mode = "manual"
        #server aanmaken en starten

        self.current_mode = ManualMode(self.movementHandler, self.logger)

        #main loop opstarten
        self.main_thread = threading.Thread(target=self.run)
        self.main_thread.start()

        #Check of we op de raspberry pi zitten
        if platform.system() != "Windows":
            #import mpu
            from MPU6050 import MPU6050
            self.MPU = MPU6050(SpinOS.logger)
            #import os.path om te kijken of de arduino er is
            import os.path
            self.serial_device = None
            #loop door verschillende usb devices. De naam veranderd namelijk soms
            for i in xrange(0, 3):
                #de naam van de usb
                serial_device = "/dev/ttyUSB" + str(i)
                #kijk of de usb er is
                if os.path.exists(serial_device):
                    #als de arduino er is moeten we serial importen
                    from Serial import Serial
                    #maak een nieuwe serial
                    self.serial = Serial(SpinOS.logger, serial_device)
                    #sla de naam van de arduino op
                    self.serial_device = serial_device
                    break
            #start de sensor thread
            self.sensor_running = True
            self.sensor_thread = threading.Thread(target=self.runSensors())
            self.sensor_thread.start()
开发者ID:hen31,项目名称:SpinDP,代码行数:59,代码来源:SpinOS.py

示例13: attendance

 def attendance():
     if not PaipaiDai.__check_attendance():
         res = Server.post('http://invest.ppdai.com/PaiMoney/PaiMoneySignin', data=None,
                           headers={'Referer': u'http://invest.ppdai.com/account/lend'})
         if res and res['Code'] > 0:
             return True
         else:
             return False
开发者ID:zhengbomo,项目名称:python_practice,代码行数:8,代码来源:PaipaiDai.py

示例14: Application

class Application(object):
	server = None
	def __init__(self):
		self.server = Server()
		
	def run(self):
		print 'Initialize'
		if not self.server.initialize():
			print 'Game server initialization fail'
			return
		print 'Initialized'
		while True:
			try:
				self.server.loop()
			except KeyboardInterrupt as e:
				print 'Keyboard interrupt!'
				self.server.stop_and_cleanup()
				return
开发者ID:karim090,项目名称:openhelbreath,代码行数:18,代码来源:HGserver.py

示例15: __init__

    def __init__(self, configPath):
        serverConfig = ServerConfig(configPath)

        self.warehouse = Warehouse(serverConfig.getWarehousePath())

        logMngr = ServerLogger()
        logMngr.addFileHandler(serverConfig.getLogDirectory())

        self.server = Server(int(serverConfig.getPortNo()),
                             serverConfig.getURLHandlers())
开发者ID:XuryaX,项目名称:lookup,代码行数:10,代码来源:Launcher.py


注:本文中的Server.Server类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。