本文整理汇总了Python中server.server函数的典型用法代码示例。如果您正苦于以下问题:Python server函数的具体用法?Python server怎么用?Python server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了server函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clientLaunch
def clientLaunch():
print ("Starting client")
server.server()
print ()
示例2: start_server
def start_server(self, *args):
args = args[0]
name = args[0]
if name in self.serverManager.server_data.keys():
if not (name in self.serverManager.servers.keys()):
self.serverManager.servers[name] = server(self.serverManager.server_data[name], self.messageQueue)
self.serverManager.servers[name].start()
elif not self.serverManager.servers[name].is_alive():
self.serverManager.servers[name] = server(self.serverManager.server_data[name], self.messageQueue)
self.serverManager.servers[name].start()
else:
return name + " is already running."
else:
return name + " is not a valid server name."
return "success"
示例3: __init__
def __init__(self):
#this function will do what is necessary to load preferences, create an empty server,
#etc, etc
self.serverlist = []
# self.s = server.server(self.tk, hostname='irc.synirc.org', nick='zobzan' )
self.createtk()
self.s = server.server(self.tk, hostname='irc.synirc.org', nick='zobzan' )
示例4: __init__
def __init__(self, name, M0b=18, M0f=23, M1b=24, M1f=25, T1=4, E1=17, simulation=False):
#GPIO: 4 17 21 22
#pin : 7 11 13 15
#GPIO: 18 23 24 25
#pin : 12 16 18 22
self.logger = logging.getLogger('myR.rover')
self.name = name
self.version = 1
self.simulation = simulation
self.ip = '192.168.0.10'
self.speed = 100 # [mm/s]
self.speedMax = 1000 # [mm/s]
self.voltage = 6 # [V]
self.mass = 2 # [Kg]
self.Lenght = 180 # [mm]
self.wheelR = 32 # [mm]
self.time360 = 2 # [sec]
self.data = datacollector()
self.camera = camera(self.data)
self.camserver = camserver(self.data)
self.sensor = us_sensor('S1', T1, E1, self.data)
self.motorLeft = DCmotor('MLeft', M0b, M0f, 11, 12)
self.motorRight = DCmotor('MRight', M1b, M1f, 13, 14)
self.rc = rc(self.data)
self.server = server(self.data)
示例5: start
def start(self, board, camera):
self.hello = "hello"
test = "test"
self.board = board
self.camera = camera
self.webServer = server.server(80, self.board, self.camera)
self.webServer.start(True)
示例6: activate
def activate(self):
ret = super(xen_driver, self).activate()
if ret: return ret
# get server object to work with
srv = server.server(self.server)
# get the kernel number from the grub config
(_,stdout,_) = srv.do_execute(
"/usr/bin/env grep -E \"^[ ]*title\" %s | " %
glob.config.get("paths", "grub_config") +
"/usr/bin/env grep -B 1000 xen | /usr/bin/env wc -l"
)
grub_number = int(stdout[0])-1
# set the xen to boot as the default kernel
srv.do_execute(
"/usr/bin/env sed -r \"s/^[ ]*default[ ]*=.*$/default=%s/g\" " %
grub_number +
"-i %s" % glob.config.get("paths", "grub_config")
)
# reboot if necessary
if self.reboot:
# backgrounded, just in case it matters
srv.do_execute("%s -r now &" % glob.config.get("paths", "shutdown"))
return errors.throw(errors.ERR_SUCCESS)
示例7: install
def install(self):
ret = super(xen_driver, self).install()
if ret: return ret
# get server object to work with
srv = server.server(self.server)
# see if it's already installed
ret = self.__installed(srv)
if ret == errors.DRIVER_ALREADY_INSTALLED:
return ret
# get distro
distro = srv.get_remote_distro()
if distro == "redhat":
# get YUM package
(exit_code,_,_) = srv.do_execute(
"yum -y install xen xen-libs kernel-xen"
)
if exit_code != 0:
return errors.throw(errors.DRIVER_INSTALL_FAIL)
return errors.throw(errors.ERR_SUCCESS)
return errors.throw(errors.DRIVER_OS_NOT_SUPPORTED)
示例8: __init__
def __init__(self, **kwargs):
super(Game, self).__init__(**kwargs)
self.players = []
self.player_count = 0
self.animals = []
self.vision = Vision()
self.server = server(self.send_status, self.add_player, self.remove_player)
self.server.main()
示例9: main
def main():
"""
Main event loop that launches a Clue-Less server and listens for incoming
connections and messages from clients.
"""
s = server.server('192.168.100.14', 4004)
#s = server.server('10.0.1.10', 4004)
while True:
try:
# Accept new connections
if s.acceptingConnections:
while True:
try:
conn, addr = s.accept()
except:
break
s.acceptConnection(conn)
# Read from connections
for name, conn in s.users.items():
try:
r = conn.recv(1024).strip()
except socket.error:
continue
message = s.decrypt(r)
if '::' in message:
splt = message.split('::')
if splt[0] == 'function':
splt2 = splt[1].split(':')
if splt2[0] == 'createNewGame':
s.createNewGame()
elif splt2[0] == 'joinGame':
s.joinGame(name, splt2[1])
elif splt2[0] == 'ready':
s.addReadyPlayer(name)
elif splt2[0] == 'start':
s.startGame(name)
elif splt2[0] == 'movePlayer':
s.handleMove(name,splt2[1])
elif splt2[0] == 'endTurn':
s.endTurn(name)
elif splt2[0] == 'makingSuggestion':
s.handleSuggestion(name,splt2[1])
elif splt2[0] == 'revealCard':
s.revealCard(name,splt2[1],splt2[2])
elif splt2[0] == 'makingAccusation':
s.handleAccusation(name,splt2[1])
elif splt[0] == 'message':
s.broadcastMessageToAll(0, '%s> %s' % (name, splt[1]))
else:
if not message:
# Empty string is given on disconnect
s.removePlayer(name)
time.sleep(.1)
except (SystemExit, KeyboardInterrupt):
break
示例10: runAll
def runAll(self):
count = 1
serv = server('192.168.2.103',52000)
serv1 = server('192.168.2.103',52002)
serv2 = server('192.168.2.103',52001)
accel = accelerometer()
meas = measure()
bAndT = batteryandtemp()
print bAndT.Batt[0]
print bAndT.Temp[0]
print bAndT.stopBase[0]
print bAndT.stopRadiom[0]
thread1 = threading.Thread(target=serv.listun,args=(0, accel,meas,bAndT))
thread2 = threading.Thread(target=serv1.listun,args=(1,accel,meas,bAndT))
thread3 = threading.Thread(target=serv2.listun,args=(2,accel,meas,bAndT))
thread1.start()
thread2.start()
thread3.start()
while count == 1 :
serv.data = map(TramAction, serv.dataT)
self.currentState.run(serv,serv2,accel,meas,bAndT)
if((bAndT.Batt[0] != 0.0 and bAndT.Batt[0] < 11.75) or (bAndT.Temp[0] != 0.0 and bAndT.Temp[0] > 40) or int(bAndT.stopBase[0]) == int(1.0) or int(bAndT.stopRadiom[0]) == int(1.0)) :
serv.dataT[0] = (str("shutdown"))
serv.data = map(TramAction, serv.dataT)
if str(serv.data[0]) == str('measure'):
serv2.wait=1
self.currentState = self.currentState.next(serv.data[0])
if(thread1.isAlive() == False) :
thread1 = threading.Thread(target=serv.listun,args=(0, accel,meas,bAndT))
thread1.start()
if(thread2.isAlive() == False) :
thread2 = threading.Thread(target=serv1.listun,args=(1,accel,meas,bAndT))
thread2.start()
if(thread3.isAlive() == False) :
thread3 = threading.Thread(target=serv2.listun,args=(2,accel,meas,bAndT))
thread3.start()
示例11: main
def main():
#print "[b]roadcast or [l]isten? Why not both!"
print "Looking for already existing network of elevators"
heis = client()
try:
result = 0
for i in range(1): # Try 3 times to connect
result = heis.start()
if result == 2: #
print "DURR"
break
elif result == 0:
while heis.alive: sleep(0.2)
print "Server died, my turn to take over"
synch = heis.server_synch
ip = heis.my_address
hardware = heis.elevator_hardware
heis.delete()
heis = server(synch[0].keys(), synch[0], ip, synch[1], hardware)
print "Takin ova"
heis.start()
break
if result == 1:
print "I am now master"
ip = heis.my_address
hardware = heis.elevator_hardware
heis.delete()
heis = server(my_ip=ip, elevator_hardware=hardware)
heis.start()
except:
print "FAIL"
print sys.exc_info()[0]
print traceback.print_tb(sys.exc_info()[2])
heis.delete()
heis.delete_driver()
exit()
示例12: __init__
def __init__(self):
#read glade file
self.builder = gtk.Builder()
self.builder.add_from_file("rad_gui.glade")
#init server
self.server = server.server(self,on_new_client_callback,on_recv_msg_callback)
self.server.start()
#get the main window, and connect all eventes
self.window = self.builder.get_object("MainForm")
if self.window:
self.builder.connect_signals(self)
self.window.show()
示例13: server
def server(args):
"""
Creates a server and sends all inputs to connected clients
"""
# Create the server object
test = sillystream_server.server()
# Start the server in a thread
test.start_thread(**args)
# In python 2x you need to send a ctrl-d to flush the buffer
# and send everything you have typed and hit enter on
for send in sys.stdin:
# Python 2x reads in unicode weird
if (sys.version_info < (3, 0)):
send = send.decode(constants.ENCODEING)
# Send any input
test.write(send)
示例14: run
def run(self):
s = server(self.host, self.port, self.username, None)
try:
if(not s.has_dir(self.path)):
s.mkdir(self.path)
s.init_git(self.path)
s.add_remote(self.path, "github", "git://github.com/" + self.gh_username + "/" + self.repo + ".git")
if not ("github" in s.get_remotes(self.path)):
s.add_remote(self.path, "github", "git://github.com/" + self.gh_username + "/" + self.repo + ".git")
s.pull(self.path, "github", self.branch)
print s.stdout + "\n========\n\n" + s.stderr
except Exception as ex:
print ex.__str__()
示例15: add_once
def add_once(self, host, port, selfreg=False, suggested=False, persistent=False, force=False, checkport=True, file=None, quicktest=False): # add server if it doesn't already exist, return (serverobject, existed)
if (not force) and self._isbanned(host, port):
debug.msg(serverlist.DBGTAG_REFUSED, "refused a banned server at %s:%d" % (host, port))
return None, False
else:
if checkport and (port < 0 or port > 65534):
debug.msg(serverlist.DBGTAG_INVALIDPORT, "trying to add a new server with an invalid port: %s:%d" % (host, port))
return
s = self.find(host, port)
if s:
existed = True
else:
s = server(host, port)
self._append(s)
existed = False
if selfreg: s.selfreg = True # whether this server has registered itself to gamemod (and not arrived via sauerbraten.org)
if (not existed) and suggested: s.suggested = True # whether this server has been suggested to gamemod and was unknown before (and not arrived via sauerbraten.org)
if persistent: s.persistent = True # whether this server should never be kicked from the pending servers list
if file: s.fromfile = file
if (not existed) and quicktest: s.quicktest = True # whether this server should be tested for registration quickly (= kick it if it does not already reply within one request and config.PING_INTERVAL)
return s, existed