本文整理汇总了Python中profile.Profile.getIntValue方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.getIntValue方法的具体用法?Python Profile.getIntValue怎么用?Python Profile.getIntValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profile.Profile
的用法示例。
在下文中一共展示了Profile.getIntValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import getIntValue [as 别名]
class pyTrainer:
def __init__(self,filename = None, data_path = None):
#Version constants
self.version ="1.10.0-dev"
#Process command line options
self.startup_options = self.get_options()
#Setup logging
self.environment = Environment(platform.get_platform(), self.startup_options.conf_dir)
self.environment.create_directories()
self.set_logging(self.startup_options.log_level, self.startup_options.log_type)
logging.debug('>>')
logging.debug("PyTrainer version %s" % (self.version))
self.data_path = data_path
self.date = Date()
self.ddbb = None
# Checking profile
logging.debug('Checking configuration and profile...')
self.profile = Profile(self.environment, self.data_path,self)
self.uc = UC()
self.windowmain = None
self.ddbb = DDBB(self.profile, self)
logging.debug('connecting to DDBB')
self.ddbb.connect()
initialize_data(self.ddbb, self.environment.conf_dir)
self._sport_service = SportService(self.ddbb)
self.record = Record(self._sport_service, data_path, self)
self.athlete = Athlete(data_path,self)
self.stats = Stats(self._sport_service, self)
pool_size = self.profile.getIntValue("pytraining","activitypool_size", default=1)
self.activitypool = ActivityPool(self, size=pool_size)
#preparamos la ventana principal
self.windowmain = Main(self._sport_service, data_path,self,self.version, gpxDir=self.profile.gpxdir)
self.date = Date(self.windowmain.calendar)
self.waypoint = Waypoint(data_path,self)
self.extension = Extension(data_path, self)
self.plugins = Plugins(data_path, self)
self.importdata = Importdata(self._sport_service, data_path, self, self.profile)
self.loadPlugins()
self.loadExtensions()
self.windowmain.setup()
self.windowmain.on_calendar_selected(None)
self.refreshMainSportList()
self.windowmain.run()
logging.debug('<<')
def get_options(self):
'''
Define usage and accepted options for command line startup
returns: options - dict with option: value pairs
'''
usage = '''usage: %prog [options]
For more help on valid options try:
%prog -h '''
parser = OptionParser(usage=usage)
parser.set_defaults(log_level=logging.ERROR, validate=False, equip=False, newgraph=True, conf_dir=None, log_type="file")
parser.add_option("-d", "--debug", action="store_const", const=logging.DEBUG, dest="log_level", help="enable logging at debug level")
parser.add_option("-i", "--info", action="store_const", const=logging.INFO, dest="log_level", help="enable logging at info level")
parser.add_option("-w", "--warn", action="store_const", const=logging.WARNING, dest="log_level", help="enable logging at warning level")
parser.add_option("--valid", action="store_true", dest="validate", help="enable validation of files imported by plugins (details at info or debug logging level) - note plugin must support validation")
parser.add_option("--oldgraph", action="store_false", dest="newgraph", help="Turn off new graphing approach")
parser.add_option("--newgraph", action="store_true", dest="newgraph", help="Deprecated Option: Turn on new graphing approach")
parser.add_option("--confdir", dest="conf_dir", help="Specify the directory where application configuration will be stored.")
parser.add_option("--logtype", dest="log_type", metavar="TYPE", type="choice" , choices=["file", "console"], help="Specify where logging should be output to. TYPE is one of 'file' (default), or 'console'.")
(options, args) = parser.parse_args()
return options
def set_logging(self, level, log_type):
'''Setup rotating log file with customized format'''
if("console" == log_type):
handler = logging.StreamHandler(sys.stdout)
else:
handler = logging.handlers.RotatingFileHandler(self.environment.log_file, maxBytes=100000, backupCount=5)
formatter = logging.Formatter('%(asctime)s|%(levelname)s|%(module)s|%(funcName)s|%(message)s')
handler.setFormatter(formatter)
logging.getLogger('').addHandler(handler)
self.set_logging_level(self.startup_options.log_level)
def set_logging_level(self, level):
'''Set level of information written to log'''
logging.debug("Setting logger to level: "+ str(level))
logging.getLogger('').setLevel(level)
def quit(self):
logging.debug('--')
logging.info("Exit!")
#self.webservice.stop()
self.windowmain.gtk_main_quit()
logging.shutdown()
sys.exit() # Any nonzero value is considered "abnormal termination" by shells and the like
def loadPlugins(self):
logging.debug('>>')
activeplugins = self.plugins.getActivePlugins()
if (len(activeplugins)<1):
logging.info("No active plugins")
#.........这里部分代码省略.........