本文整理汇总了Python中config.Configuration.getParam方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.getParam方法的具体用法?Python Configuration.getParam怎么用?Python Configuration.getParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Configuration
的用法示例。
在下文中一共展示了Configuration.getParam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import getParam [as 别名]
def __init__(self, *pars, **kpars):
AnchorLayout.__init__(self, *pars, **kpars)
self.cur_dir = dirname(abspath('file'))
config = Configuration()
config.purgelines()
config.initialize()
# do not use '-' or other chars in the name!
self.username = ''
self.turnables = config.getParam('turnable')
self.cards_unturnable = bool(int(config.getParam('cards_unturnable')))
# enables the automatic player agent, playing as NK as default.
self.rp = None # Rule Parser
self.auto_player = bool(int(config.getParam('auto_player')))
if self.auto_player:
self.rp = RuleParser()
self.rp.load_rules()
self.format = config.getParam('format')
self.help_file = config.getParam('help_file')
self.shoe_file = config.getParam('shoe_file')
self.srv = config.getParam('server')
self.srv_port = config.getParam('server_port')
if self.format == 'circular':
self.turnable = dict(zip(TTTGame.CIRCULAR_CARD_LAYOUT, [bool(int(x)) for x in self.turnables.split(',')]))
else:
self.turnable = dict(zip(TTTGame.LINEAR_CARD_LAYOUT, [bool(int(x)) for x in self.turnables.split(',')]))
self.timer_start = int(config.getParam('timer_start'))
# load default shoe_file:
self.shoe_config = Configuration(config_file=self.shoe_file)
self.shoe_config.purgelines()
# self.turn = '' # current player turn
self.current_target_card = '' # the target card stated in the shoe_file ("2H" usually)
print self.shoe_config.content
self.hands = [] # store all hands
# file names are in the form: output-<dmY>-<HM>.txt
# Here we just create a reference. The actual obj is made when the login popup is dismissed
self.fout_handle = None
self.fout_time_handle = None
self.timeHistory = [] # list holding the strings: <move> <time>\n
self.stopwatch = StopWatch()
self.nk_history_q = deque([], 2) # nk history of the last 2 hands. Required for automatic agent
self.ck_history_q = deque([], 2) # ck history of the last 2 hands. Required for automatic agent
示例2: build
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import getParam [as 别名]
def build(self):
server = LogServer()
cfg = Configuration(config_file='server-config.txt')
cfg.purgelines()
cfg.initialize()
try:
reactor.listenTCP(LogServerApp.port, LogProtocolFactory(self,
server_shoe_file='data/' + cfg.getParam('shoe_file'),
users_shoe_file='data/' + cfg.getParam('users_shoe_file')))
LogServerApp.service_p = TTTMulticastDiscoveryCI(TTTMulticastDiscoveryCI.MODES['server'], LogServerApp.port)
reactor.listenMulticast(TTTMulticastDiscoveryCI.PORT, LogServerApp.service_p, listenMultiple=True)
except Exception as e:
print e
pass
LogServerApp.s = server
return server
示例3: TTTGameApp
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import getParam [as 别名]
class TTTGameApp(App):
connection = None
g = None
def build(self):
global g
self.nr = 0
self.config = Configuration()
self.config.purgelines()
self.config.initialize()
game = TTTGame()
self.g = game
self.mp = TTTMulticastDiscoveryCI(TTTMulticastDiscoveryCI.MODES['client'])
reactor.listenMulticast(TTTMulticastDiscoveryCI.PORT, self.mp, listenMultiple=True)
Clock.schedule_once(lambda dt: game.post_init())
Clock.schedule_once(lambda dt: self.discover_server(), 1)
return game
def connect_to_server(self, host, port):
reactor.connectTCP(host, port, LogClientFactory(self))
# reactor.connectTCP(host, port, EchoClientFactory(self))
def on_connection(self, connection):
self.connection = connection
print 'Connected to server!'
self.g.console.text += 'Connected to server %s\n' % connection.transport.getPeer()
self.g.connection_popup.quit()
self.login()
def login(self):
self.g.show_login_popup()
def on_connection_failed(self, reason):
self.g.connection_popup.update_label(' Connection FAILED')
def send_message(self, data):
"""Send the whole data content to the connection handle.
"""
if data and self.connection:
self.connection.sendLine(str(data))
def discover_server(self):
if self.nr < 3:
if len(self.mp.servers) == 0:
print "No servers yet"
self.mp.query()
Clock.schedule_once(lambda dt: self.discover_server(), 5)
self.nr += 1
else:
ips = self.mp.servers.keys()
# print 'Discovered server: %s at port %d\n' % (ips[0], self.mp.servers[ips[0]])
self.g.console.text += 'Discovered server: %s @ port %d\n' % (ips[0], self.mp.servers[ips[0]])
self.connect_to_server(ips[0], self.mp.servers[ips[0]])
else:
print "Multicast failed, trying direct connection..."
self.connect_to_server(self.config.getParam('server'), int(self.config.getParam('server_port')))
def receive(self, msg):
if msg.startswith('ask_reply'):
lines = msg.split('\n')
lines = [x for x in lines if x != '' and not x.startswith('#') and
not x.startswith('//') ]
print lines[1:]
self.g.shoe_config.content = lines[1:]
self.g.total_runs = len(self.g.shoe_config.content) # updates counter in GUI
# g.console.text += msg + '\n'
def log(self, msg, log='MOVES',):
self.send_message('log:' + log)
self.send_message(msg)