本文整理汇总了Python中Server.Server.start方法的典型用法代码示例。如果您正苦于以下问题:Python Server.start方法的具体用法?Python Server.start怎么用?Python Server.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Server
的用法示例。
在下文中一共展示了Server.start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import start [as 别名]
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'
示例2: MyServer
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import start [as 别名]
class MyServer(QtGui.QMainWindow):
def __init__(self, parent=None):
#Instance variables
self.chatLines = []
self.consoleLines = []
self.lastServerLine = ''
#Initialize a QTimer to run background updates (online players, status, new chat messages, etc)
self.repeatingTimer = QtCore.QTimer()
self.singleTimer = QtCore.QTimer()
self.s=Server()
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.initUI()
self.startRepeatingTimer()
self.sendMessageClicked()
self.consoleClicked()
self.onlineClicked()
def initUI(self):
self.connect(self.ui.pushButtonStart, QtCore.SIGNAL('clicked()'), self.startClicked)
self.connect(self.ui.pushButtonStop, QtCore.SIGNAL('clicked()'), self.stopClicked)
self.connect(self.ui.pushButtonStopStart, QtCore.SIGNAL('clicked()'), self.stopStartClicked)
self.connect(self.ui.pushButtonStatus, QtCore.SIGNAL('clicked()'), self.statusClicked)
self.connect(self.ui.pushButtonOnline, QtCore.SIGNAL('clicked()'), self.onlineClicked)
self.connect(self.ui.pushButtonSendMessage, QtCore.SIGNAL('clicked()'), self.sendMessageClicked)
self.connect(self.ui.lineEditMessage, QtCore.SIGNAL('returnPressed()'), self.sendMessageClicked)
self.connect(self.ui.pushButtonConsole, QtCore.SIGNAL('clicked()'), self.consoleClicked)
self.connect(self.ui.lineEditConsole, QtCore.SIGNAL('returnPressed()'), self.consoleClicked)
#Connect the timer button
self.connect(self.ui.pushButtonStartTimer, QtCore.SIGNAL('clicked()'), self.startRepeatingTimer)
#Connect the timer
self.connect(self.repeatingTimer, QtCore.SIGNAL('timeout()'), self.ticToc)
def startClicked(self):
self.s.start()
self.checkStatus()
def stopClicked(self):
self.s.stop()
self.checkStatus()
def statusClicked(self):
self.checkStatus()
def onlineClicked(self):
self.players = self.s.players()
playersFormatted = ''
if self.players == ['']:
playersFormatted = 'No one online. Click to refresh'
elif len(self.players) is 1 and self.players[0] != '':
playersFormatted = self.players[0]
else:
for player in self.players:
playersFormatted = playersFormatted + ' ' + player
self.ui.labelOnline.setText(playersFormatted)
def sendMessageClicked(self):
message = self.ui.lineEditMessage.text()
self.ui.lineEditMessage.clear()
if message != '':
self.s.message(message)
if len(self.chatLines) is 0:
self.chatLines = self.s.chat(60)
newChatLines = self.chatLines
else:
newChatLine = 'poop'
searchBack = 0
while newChatLine not in self.chatLines[-2:]:
searchBack = searchBack + 1
newChatLine = self.s.chat(searchBack, oneLine=True)
newChatLines = self.s.chat(searchBack)
newChatLines.pop(0)
if len(newChatLines) > 0:
for line in newChatLines:
fixedLine = line[5:19] + line[26:]
width = self.ui.treeWidgetChat.columnWidth(0)
fixedLine = utils.wordWrap(width-5, fixedLine)
a = QtGui.QTreeWidgetItem(self.ui.treeWidgetChat)
a.setText(0, fixedLine)
self.ui.treeWidgetChat.scrollToItem(a)
self.chatLines.extend(newChatLines)
#.........这里部分代码省略.........
示例3: Server
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import start [as 别名]
'''
Created on 2010/01/08
@author: Solivagant
'''
from Server import Server
server = Server()
server.start()
示例4: setUpClass
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import start [as 别名]
def setUpClass(cls):
Server.attachLogger('at.log')
Server.start()
示例5: CBM1
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import start [as 别名]
"password": "",
"port": 23,
"protocal": ""
}
CBM, CORE, SERVER = read_Config.read_Config(CBM, CORE, SERVER)
condition1=threading.Condition()
condition2=threading.Condition()
condition3=threading.Condition()
'''
Check the Schedule configuration and check the file query before calling occured.
'''
cbm1 = CBM1(condition1, 'CBM1',CBM["hostname"],CBM["username"],CBM["RootPassword"],CBM["password"],CBM["port"]) #create two thread within a condition lock
server = Server(condition1,'Server',"202.38.35.184","bsmbin","Abcde01!",23,fileDirection,0)
server.start() #server start first but the thread will set to wait when acquire the lock
cbm1.start() #Though start later but the thread will finish its processing first
cbm1.join()
server.join() #Main thread wait until the thread above finish their tasks
'''
Calling happens with the command sent in Core.And then CBM will check the FIlESYS to findout whether the Billing is in the query
'''
cbm2 = CBM2(condition2, 'CBM2',"10.178.28.26","nortel","nortel",22) #create two thread within a condition lock
core = Core(condition2,'Core',"10.24.16.134","lisa","lisa",23)
cbm2.start() #cbm2 start first but the thread will set to wait when acquire the lock
core.start() #Though start later but the thread will finish its processing first
core.join()
cbm2.join() #Main thread wait until the thread above finish their tasks
示例6:
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import start [as 别名]
#!/usr/bin/python
from Server import Server
Server.start()
示例7: MyServer
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import start [as 别名]
class MyServer(QtGui.QMainWindow):
def __init__(self, parent=None):
#Are we local or remote?
self.remote = True
#Instantiate a minecraft server object
self.s=Server(remote=self.remote)
#The usual
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.initUI()
#Instance variables
self.chatLines = []
self.consoleLines = []
self.onlineDict = {}
self.pluginsDict = {}
#Set the start/stop button text
if self.s.status():
self.ui.pushButtonStopStart.setText('Stop Server')
else:
self.ui.pushButtonStopStart.setText('Start Server')
if self.remote:
print 'spawning remote thread'
self.connect(self, QtCore.SIGNAL('newRemoteLines'), self.routeServerLines)
self.connect(self, QtCore.SIGNAL('pluginsDict'), self.remotePlugins)
self.thread = GenericThread(self.remoteConn)
self.thread.start()
print 'thread started'
else:
#Instantiate a qThreadWatcher() to monitor server.log for changes and connect its signal
#to newLineDetected.
self.fileWatcher = QtCore.QFileSystemWatcher(self)
self.fileWatcher.addPath(os.path.join(self.s.bukkitDir, 'server.log'))
self.connect(self.fileWatcher, QtCore.SIGNAL('fileChanged(QString)'), self.newLineDetected)
#Find the currently installed plugins by searching the plugin folder
self.findPlugins()
#On app boot, read til the last time the server was started
self.lastServerLine = ' [INFO] Stopping server'
self.newLineDetected()
#Initialize a QTimer to run and connect it to ticToc
self.repeatingTimer = QtCore.QTimer()
self.repeatingTimer.start(1000)
self.connect(self.repeatingTimer, QtCore.SIGNAL('timeout()'), self.ticToc)
def initUI(self):
#Connect the UI buttons
self.connect(self.ui.pushButtonStopStart, QtCore.SIGNAL('clicked()'), self.stopStartClicked)
self.connect(self.ui.lineEditMessage, QtCore.SIGNAL('returnPressed()'), self.sendChat)
self.connect(self.ui.lineEditConsole, QtCore.SIGNAL('returnPressed()'), self.sendConsole)
self.connect(self.ui.treeWidgetPluginList, QtCore.SIGNAL('itemSelectionChanged()'), self.pluginNameClicked)
#####################
#GUI control methods
#####################
#Start or stop the server
def handleStopStart(self):
if self.s.status():
self.s.stop()
setName = 'Start'
else:
self.s.start()
setName = 'Stop'
self.emit(QtCore.SIGNAL('stopStartDone(QString)'), setName)
#This method is called when the stopStart thread (handleStopStart()) has finished
def stopStartDone(self, setName):
self.ui.pushButtonStopStart.setEnabled(True)
self.ui.pushButtonStopStart.setText(setName + ' Server')
self.updateStatusBar()
#This method spawns a thread to stop or start the server
def stopStartClicked(self):
self.ui.pushButtonStopStart.setEnabled(False)
self.ui.statusbar.showMessage('Trying...')
self.stopStartThread = GenericThread(self.handleStopStart)
self.disconnect( self, QtCore.SIGNAL("stopStartDone(QString)"), self.stopStartDone )
self.connect( self, QtCore.SIGNAL("stopStartDone(QString)"), self.stopStartDone )
self.stopStartThread.start()
def updateStatusBar(self):
if self.s.status():
line = 'SERVER IS ON - Players Online: ' + str(len(self.onlineDict))
else:
line = 'SERVER IS OFF'
self.ui.statusbar.showMessage(line)
def sendChat(self):
#.........这里部分代码省略.........
示例8: Server
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import start [as 别名]
server_id='bob')
bob = Server(name='bob',
g=g,
p=p,
input_queue=queue_to_server,
output_queue=queue_to_client,
rsa_obj=rsa_bob,
keys=keys,
client_id='alice')
assert alice.K is None
assert bob.K is None
assert alice.finished_successfully is None
assert bob.finished_successfully is None
alice.start()
bob.start()
alice.join(timeout=50)
bob.join(timeout=50)
killed = False
if alice.is_alive():
alice._Thread__stop()
killed = True
if bob.is_alive():
bob._Thread__stop()
killed = True
if killed:
sys.exit(1)
assert alice.finished_successfully is True
assert bob.finished_successfully is True
assert alice.K == bob.K