本文整理汇总了Python中scheduler.Scheduler.__subclasses__方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.__subclasses__方法的具体用法?Python Scheduler.__subclasses__怎么用?Python Scheduler.__subclasses__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scheduler.Scheduler
的用法示例。
在下文中一共展示了Scheduler.__subclasses__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import __subclasses__ [as 别名]
def main():
parser = optparse.OptionParser(description='bitHopper')
parser.add_option('--debug', action= 'store_true', default = False, help='Log twisted output')
parser.add_option('--trace', action= 'store_true', default = False, help='Extra debugging output')
parser.add_option('--listschedulers', action='store_true', default = False, help='List alternate schedulers available')
parser.add_option('--port', type = int, default=8337, help='Port to listen on')
parser.add_option('--scheduler', type=str, default=None, help='Select an alternate scheduler')
parser.add_option('--threshold', type=float, default=None, help='Override difficulty threshold (default 0.43)')
parser.add_option('--altslicesize', type=int, default=900, help='Override Default AltSliceScheduler Slice Size of 900')
parser.add_option('--altminslicesize', type=int, default=60, help='Override Default Minimum Pool Slice Size of 60 (AltSliceScheduler only)')
parser.add_option('--altslicejitter', type=int, default=0, help='Add some random variance to slice size, disabled by default (AltSliceScheduler only)')
parser.add_option('--altsliceroundtimebias', action='store_true', default=False, help='Bias slicing slightly by round time duration with respect to round time target (default false)')
parser.add_option('--altsliceroundtimetarget', type=int, default=1000, help='Round time target based on GHash/s (default 1000 Ghash/s)')
parser.add_option('--altsliceroundtimemagic', type=int, default=10, help='Round time magic number, increase to bias towards round time over shares')
parser.add_option('--p2pLP', action='store_true', default=False, help='Starts up an IRC bot to validate LP based hopping.')
parser.add_option('--OldConnectionSystem', action='store_true', default=False, help='Uses the old connection system. May help with lots of miners')
parser.add_option('--ip', type = str, default='', help='IP to listen on')
parser.add_option('--auth', type = str, default=None, help='User,Password')
options = parser.parse_args()[0]
if options.trace == True: options.debug = True
if options.listschedulers:
schedulers = ""
for s in scheduler.Scheduler.__subclasses__():
schedulers += ", " + s.__name__
print "Available Schedulers: " + schedulers[2:]
return
bithopper_instance = BitHopper(options)
if options.auth:
auth = options.auth.split(',')
bithopper_instance.auth = auth
if len(auth) != 2:
print 'User,Password. Not whatever you just entered'
return
if options.scheduler:
bithopper_instance.log_msg("Selecting scheduler: " + options.scheduler)
foundScheduler = False
for s in Scheduler.__subclasses__():
if s.__name__ == options.scheduler:
bithopper_instance.scheduler = s(bithopper_instance)
foundScheduler = True
break
if not foundScheduler:
bithopper_instance.log_msg("Error couldn't find: " + options.scheduler + ". Using default scheduler.")
bithopper_instance.scheduler = scheduler.DefaultScheduler(bithopper_instance)
else:
bithopper_instance.log_msg("Using default scheduler.")
bithopper_instance.scheduler = scheduler.DefaultScheduler(bithopper_instance)
bithopper_instance.select_best_server()
if options.debug:
log.startLogging(sys.stdout)
if options.p2pLP:
bithopper_instance.log_msg('Starting p2p LP')
bithopper_instance.lpBot = LpBot(bithopper_instance)
site = server.Site(website.bitSite(bithopper_instance))
reactor.listenTCP(options.port, site, 20, options.ip)
reactor.run()
bithopper_instance.db.close()
示例2: main
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import __subclasses__ [as 别名]
def main():
parser = optparse.OptionParser(description='bitHopper')
parser.add_option('--noLP', action = 'store_true' ,default=False, help='turns off client side longpolling')
parser.add_option('--debug', action= 'store_true', default = False, help='Use twisted output')
parser.add_option('--listschedulers', action='store_true', default = False, help='List alternate schedulers available')
parser.add_option('--list', action= 'store_true', default = False, help='List servers')
parser.add_option('--disable', type=str, default = None, action='callback', callback=parse_server_disable, help='Servers to disable. Get name from --list. Servera,Serverb,Serverc')
parser.add_option('--port', type = int, default=8337, help='Port to listen on')
parser.add_option('--scheduler', type=str, default=None, help='Select an alternate scheduler')
parser.add_option('--threshold', type=float, default=None, help='Override difficulty threshold (default 0.43)')
parser.add_option('--altslicesize', type=int, default=900, help='Override Default AltSliceScheduler Slice Size of 900')
parser.add_option('--altminslicesize', type=int, default=60, help='Override Default Minimum Pool Slice Size of 60 (AltSliceScheduler only)')
parser.add_option('--altslicejitter', type=int, default=0, help='Add some random variance to slice size, disabled by default (AltSliceScheduler only)')
parser.add_option('--startLP', action= 'store_true', default = False, help='Seeds the LP module with known pools. Must use it for LP based hopping with deepbit')
args, rest = parser.parse_args()
options = args
bithopper_global.options = args
if options.list:
for k in bithopper_global.pool.get_servers():
print k
return
if options.listschedulers:
schedulers = None
for s in Scheduler.__subclasses__():
if schedulers != None: schedulers = schedulers + ", " + s.__name__
else: schedulers = s.__name__
print "Available Schedulers: " + schedulers
return
if options.scheduler:
bithopper_global.log_msg("Selecting scheduler: " + options.scheduler)
foundScheduler = False
for s in Scheduler.__subclasses__():
if s.__name__ == options.scheduler:
bithopper_global.scheduler = s(bithopper_global)
foundScheduler = True
break
if foundScheduler == False:
bithopper_global.log_msg("Error couldn't find: " + options.scheduler + ". Using default scheduler.")
bithopper_global.scheduler = scheduler.DefaultScheduler(bithopper_global)
else:
bithopper_global.log_msg("Using default scheduler.")
bithopper_global.scheduler = scheduler.DefaultScheduler(bithopper_global)
bithopper_global.select_best_server()
if options.disable != None:
for k in options.disable:
if k in bithopper_global.pool.get_servers():
if bithopper_global.pool.get_servers()[k]['role'] == 'backup':
bithopper_global.log_msg("You just disabled the backup pool. I hope you know what you are doing")
bithopper_global.pool.get_servers()[k]['role'] = 'disable'
else:
bithopper_global.log_msg(k + " Not a valid server")
if options.debug: log.startLogging(sys.stdout)
if options.startLP:
bithopper_global.log_msg( 'Starting LP')
startlp = LoopingCall(bithopper_global.lp.start_lp)
startlp.start(60*30)
site = server.Site(website.bitSite(bithopper_global))
reactor.listenTCP(options.port, site)
reactor.callLater(0, bithopper_global.pool.update_api_servers, bithopper_global)
delag_call = LoopingCall(bithopper_global.delag_server)
delag_call.start(119)
reactor.run()
bithopper_global.db.close()
示例3: main
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import __subclasses__ [as 别名]
def main():
parser = optparse.OptionParser(description='bitHopper')
parser.add_option('--debug', action= 'store_true', default = False, help='Extra error output. Basically print all caught errors')
parser.add_option('--trace', action= 'store_true', default = False, help='Extra debugging output')
parser.add_option('--listschedulers', action='store_true', default = False, help='List alternate schedulers available')
parser.add_option('--port', type = int, default=8337, help='Port to listen on')
parser.add_option('--scheduler', type=str, default='OldDefaultScheduler', help='Select an alternate scheduler')
parser.add_option('--threshold', type=float, default=None, help='Override difficulty threshold (default 0.43)')
parser.add_option('--altslicesize', type=int, default=900, help='Override Default AltSliceScheduler Slice Size of 900')
parser.add_option('--altminslicesize', type=int, default=60, help='Override Default Minimum Pool Slice Size of 60 (AltSliceScheduler only)')
parser.add_option('--altslicejitter', type=int, default=0, help='Add some random variance to slice size, disabled by default (AltSliceScheduler only)')
parser.add_option('--altsliceroundtimebias', action='store_true', default=False, help='Bias slicing slightly by round time duration with respect to round time target (default false)')
parser.add_option('--altsliceroundtimetarget', type=int, default=1000, help='Round time target based on GHash/s (default 1000 Ghash/s)')
parser.add_option('--altsliceroundtimemagic', type=int, default=10, help='Round time magic number, increase to bias towards round time over shares')
parser.add_option('--config', type=str, default='bh.cfg', help='Select an alternate main config file from bh.cfg')
parser.add_option('--p2pLP', action='store_true', default=False, help='Starts up an IRC bot to validate LP based hopping.')
parser.add_option('--ip', type = str, default='', help='IP to listen on')
parser.add_option('--auth', type = str, default=None, help='User,Password')
parser.add_option('--logconnections', default = False, action='store_true', help='show connection log')
options = parser.parse_args()[0]
if options.trace == True: options.debug = True
if options.listschedulers:
schedulers = ""
for s in scheduler.Scheduler.__subclasses__():
schedulers += ", " + s.__name__
print "Available Schedulers: " + schedulers[2:]
return
config = ConfigParser.ConfigParser()
try:
# determine if application is a script file or frozen exe
if hasattr(sys, 'frozen'):
application_path = os.path.dirname(sys.executable)
elif __file__:
application_path = os.path.dirname(__file__)
if not os.path.exists(os.path.join(application_path, options.config)):
print "Missing " + options.config + " may need to rename bh.cfg.default"
os._exit(-1)
config.read(os.path.join(application_path, options.config))
except:
if not os.path.exists(options.config):
print "Missing " + options.config + " may need to rename bh.cfg.default"
os._exit(-1)
config.read(options.config)
bithopper_instance = BitHopper(options, config)
if options.auth:
auth = options.auth.split(',')
bithopper_instance.auth = auth
if len(auth) != 2:
print 'User,Password. Not whatever you just entered'
return
# auth from config
try:
c = config.get('auth', 'username'), config.get('auth', 'password')
bithopper_instance.auth = c
except:
pass
override_scheduler = False
if options.scheduler != None:
scheduler_name = options.scheduler
override_scheduler = True
try:
sched = config.get('main', 'scheduler')
if sched != None:
override_scheduler = True
scheduler_name = sched
except:
pass
if override_scheduler:
bithopper_instance.log_msg("Selecting scheduler: " + scheduler_name)
foundScheduler = False
for s in Scheduler.__subclasses__():
if s.__name__ == scheduler_name:
bithopper_instance.scheduler = s(bithopper_instance)
foundScheduler = True
break
if not foundScheduler:
bithopper_instance.log_msg("Error couldn't find: " + scheduler_name + ". Using default scheduler.")
bithopper_instance.scheduler = scheduler.DefaultScheduler(bithopper_instance)
else:
bithopper_instance.log_msg("Using default scheduler.")
bithopper_instance.scheduler = scheduler.DefaultScheduler(bithopper_instance)
bithopper_instance.select_best_server()
if options.p2pLP:
bithopper_instance.log_msg('Starting p2p LP')
bithopper_instance.lpBot = LpBot(bithopper_instance)
lastDefaultTimeout = socket.getdefaulttimeout()
if options.debug:
backdoor_port = config.getint('backdoor', 'port')
#.........这里部分代码省略.........