本文整理汇总了Python中SearchModule.loadSearchModules方法的典型用法代码示例。如果您正苦于以下问题:Python SearchModule.loadSearchModules方法的具体用法?Python SearchModule.loadSearchModules怎么用?Python SearchModule.loadSearchModules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchModule
的用法示例。
在下文中一共展示了SearchModule.loadSearchModules方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_obsolete_providers
# 需要导入模块: import SearchModule [as 别名]
# 或者: from SearchModule import loadSearchModules [as 别名]
def filter_obsolete_providers(self):
#~ avoids obsolete modules to appear in the search routine
#~ this is an additional safety measure
if 'loadedModules' not in globals():
SearchModule.loadSearchModules()
saved_cfg = []
for index in xrange(len(self.cfg)):
index_found = False
for module in SearchModule.loadedModules:
if( module.typesrch == self.cfg[index]['type']):
index_found = True
if(index_found is True):
saved_cfg.append(self.cfg[index])
self.cfg = copy.deepcopy(saved_cfg)
示例2: html_builtin_output
# 需要导入模块: import SearchModule [as 别名]
# 或者: from SearchModule import loadSearchModules [as 别名]
def html_builtin_output(cffile, genopt):
count = 0
if 'SearchModule.loadedModules' not in globals():
SearchModule.loadSearchModules()
cffileb = []
for module in SearchModule.loadedModules:
if(module.builtin):
option='checked=yes'
flogin=0
login_name = ''
login_pwd = ''
if(module.active == 0):
option=''
for i in xrange(len(cffile)):
if(cffile[i]['type'] == module.typesrch):
if(cffile[i]['valid'] == '0'):
option=''
else:
option='checked=yes'
login_name=cffile[i]['login']
login_pwd=cffile[i]['pwd']
if(module.login == 1):
flogin = 1
tmpcfg= {'stchk' : option,
'humanname' : module.name,
'idx' : count,
'type' : module.typesrch,
'flogin': flogin,
'loginname': login_name,
'loginpwd': login_pwd,
}
cffileb.append(tmpcfg)
count = count + 1
count = 0
for i in xrange(len(cffile)):
if(cffile[i]['builtin'] == 0):
cffile[i]['idx'] = count
count = count + 1
return render_template('config.html', cfg=cffile, cnt=count, genopt = genopt, cnt_max=MAX_PROVIDER_NUMBER, cfg_bi=cffileb)
示例3: html_editpage
# 需要导入模块: import SearchModule [as 别名]
# 或者: from SearchModule import loadSearchModules [as 别名]
def html_editpage(self):
count = 0
if 'SearchModule.loadedModules' not in globals():
SearchModule.loadSearchModules()
dsearchsupport = DeepsearchModule.supportedengines()
cffileb = []
cffile = copy.deepcopy(self.cfg)
cdsfile = self.cfg_deep
genopt = self.cgen
if (cffile is None):
cffile = []
if (cdsfile is None):
cdsfile = []
cdomainname = megasearch.getdomainext()
for module in SearchModule.loadedModules:
if (module.builtin):
option = 'checked=yes'
flogin = 0
flogin_caption_user = 'login'
flogin_caption_pwd = 'pwd'
login_name = ''
login_pwd = ''
speed_cl = 1
extra_cl = 0
if (module.active == 0):
option = ''
for i in xrange(len(cffile)):
if (cffile[i]['type'] == module.typesrch):
if (cffile[i]['valid'] == 0):
option = ''
else:
option = 'checked=yes'
login_name = cffile[i]['login']
login_pwd = cffile[i]['pwd']
speed_cl = cffile[i]['speed_class']
extra_cl = cffile[i]['extra_class']
if (module.login == 1):
flogin = 1
# ~ if('caption_login_user' in module):
if (hasattr(module, 'caption_login_user')):
flogin_caption_user = module.caption_login_user
flogin_caption_pwd = module.caption_login_pwd
tmpcfg = {'stchk': option,
'humanname': module.name,
'url': '',
'idx': count,
'speed_class': speed_cl,
'extra_class': extra_cl,
'type': module.typesrch,
'flogin': flogin,
'flogin_caption_user': flogin_caption_user,
'flogin_caption_pwd': flogin_caption_pwd,
'loginname': login_name,
'loginpwd': login_pwd,
}
cffileb.append(tmpcfg)
count = count + 1
# ~ scrapers with web login
for dsearchmodule in dsearchsupport:
if (dsearchmodule['opts']['builtin']):
option = 'checked=yes'
flogin = 0
login_name = ''
login_pwd = ''
speed_cl = dsearchmodule['opts']['speed_cl']
extra_cl = dsearchmodule['opts']['extra_cl']
if (dsearchmodule['opts']['active'] == 0):
option = ''
for i in xrange(len(cdsfile)):
if (cdsfile[i]['type'] == dsearchmodule['opts']['typesrch']):
if (cdsfile[i]['valid'] == 0):
option = ''
else:
option = 'checked=yes'
# ~ speed_cl = cdsfile[i]['speed_cl']
login_name = cdsfile[i]['user']
login_pwd = cdsfile[i]['pwd']
if (dsearchmodule['opts']['login'] == 1):
flogin = 1
tmpcfg = {'stchk': option,
'humanname': dsearchmodule['name'],
'url': dsearchmodule['opts']['url'],
'idx': count,
'flogin_caption_user': 'login',
'flogin_caption_pwd': 'pwd',
'speed_class': speed_cl,
'extra_class': extra_cl,
'type': dsearchmodule['opts']['typesrch'],
#.........这里部分代码省略.........
示例4: beam_cookie
# 需要导入模块: import SearchModule [as 别名]
# 或者: from SearchModule import loadSearchModules [as 别名]
def beam_cookie(self, urltouse, args):
retfail = -1
global globalResults
if 'loadedModules' not in globals():
SearchModule.loadSearchModules()
cookie = {}
dwntype = 0
index = 0
selcfg_idx = 0
# ~ take the right password
for i in xrange(len(self.cfg)):
if (self.cfg[i]['type'] == args['m']):
selcfg_idx = i
# ~ standard search
for module in SearchModule.loadedModules:
if (module.typesrch == args['m']):
dwntype = 0
if (module.dologin(self.cfg[selcfg_idx]) == True):
cookie = module.cookie
else:
return retfail
# ~ deep search
deepidx = 0
for index in xrange(len(self.dsearch.ds)):
if (self.dsearch.ds[index].typesrch == args['m']):
dwntype = 1
deepidx = index
f_name = ''
if (dwntype == 0):
# ~ log.info('WARPNGN Cookie FTD found')
try:
opener = urllib2.build_opener()
opener.addheaders.append(('Cookie', 'FTDWSESSID=' + cookie['FTDWSESSID']))
response = opener.open(urltouse)
except Exception as e:
return retfail
if (dwntype == 1):
# ~ log.info('WARPNGN Cookie deep found')
response = self.dsearch.ds[deepidx].download(urltouse)
if (response == ''):
return -1
fcontent = response.read()
# ~ print response.info()
f = tempfile.NamedTemporaryFile(delete=False)
f.write(fcontent)
f.close()
fresponse = send_file(f.name, mimetype='application/x-nzb;', as_attachment=True,
attachment_filename='yourmovie.nzb', add_etags=False, cache_timeout=None,
conditional=False)
try:
os.remove(f.name)
except Exception as e:
print 'Cannot remove temporary NZB file'
riff_never = True
for i in xrange(len(response.info().headers)):
if (response.info().headers[i].find('Content-Encoding') != -1):
fresponse.headers["Content-Encoding"] = 'gzip'
riff = response.info().headers[i].find('Content-Disposition')
if (riff != -1):
riff_never = False
fresponse.headers["Content-Disposition"] = response.info().headers[i][
riff + 21:len(response.info().headers[i])].strip()
# ~ conservative case -- nothing found
if (riff_never == True):
last_slash = urltouse.rfind('/')
nzb_xt = urltouse.lower().rfind('.nzb')
if (last_slash != -1 and nzb_xt != -1):
fresponse.headers["Content-Disposition"] = 'attachment; filename="' + urltouse[
last_slash + 1:nzb_xt] + '.nzb"'
# ~ print '['+fresponse.headers["Content-Disposition"]+']'
return fresponse
示例5: loginit
# 需要导入模块: import SearchModule [as 别名]
# 或者: from SearchModule import loadSearchModules [as 别名]
cfgsets = config_settings.CfgSettings()
first_time = 0
#~ init logger
log = loginit()
#~ bootstrap
reload_all()
if (cfgsets.cfg is None or cfgsets.cfg_deep is None ):
first_time = 1
'>> It will be configured'
certdir = SearchModule.resource_path('certificates/')
templatedir = SearchModule.resource_path('templates')
app = Flask(__name__, template_folder=templatedir)
SearchModule.loadSearchModules()
if(DEBUGFLAG):
cfgsets.cgen['general_trend'] = 0
cfgsets.cgen['general_suggestion'] = 0
print '====== DEBUGFLAG MUST BE SET TO FALSE BEFORE DEPLOYMENT ======'
#~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
@app.route('/poweroff', methods=['GET'])
@auth.requires_auth
def poweroff():
if(cfgsets.cgen['large_server'] == False):
if('sid' in request.args):
if(request.args['sid'] == sessionid_string):
os._exit(0)
return main_index()
示例6: html_editpage
# 需要导入模块: import SearchModule [as 别名]
# 或者: from SearchModule import loadSearchModules [as 别名]
def html_editpage(self):
count = 0
if 'SearchModule.loadedModules' not in globals():
SearchModule.loadSearchModules()
cffileb = []
cffile = copy.deepcopy(self.cfg)
cdsfile = self.cfg_deep
genopt = self.cgen
if(cffile is None):
cffile = []
if(cdsfile is None):
cdsfile = []
for module in SearchModule.loadedModules:
if(module.builtin):
option='checked=yes'
flogin=0
login_name = ''
login_pwd = ''
speed_cl = 1
if(module.active == 0):
option=''
for i in xrange(len(cffile)):
if(cffile[i]['type'] == module.typesrch):
if(cffile[i]['valid'] == 0):
option=''
else:
option='checked=yes'
login_name=cffile[i]['login']
login_pwd=cffile[i]['pwd']
speed_cl = cffile[i]['speed_class']
if(module.login == 1):
flogin = 1
tmpcfg= {'stchk' : option,
'humanname' : module.name,
'idx' : count,
'speed_class' : speed_cl,
'type' : module.typesrch,
'flogin': flogin,
'loginname': login_name,
'loginpwd': login_pwd,
}
cffileb.append(tmpcfg)
count = count + 1
count = 0
for i in xrange(len(cffile)):
if(cffile[i]['builtin'] == 0):
cffile[i]['idx'] = count
cffile[i]['valid_verbose'] = ''
if(cffile[i]['valid'] == 1):
cffile[i]['valid_verbose'] = 'checked=yes'
count = count + 1
sel_speedopt_tmp = copy.deepcopy(self.selectable_speedopt)
sel_speedopt_tmp[cffile[i]['speed_class']-1][2] = 'selected'
cffile[i]['selspeed_sel'] = sel_speedopt_tmp
sel_speedopt_basic = copy.deepcopy(self.selectable_speedopt)
sel_speedopt_basic[0][2] = 'selected'
count_ds=0
for i in xrange(len(cdsfile)):
cdsfile[i]['idx'] = count_ds
cdsfile[i]['valid_verbose'] = ''
if(cdsfile[i]['valid'] == 1):
cdsfile[i]['valid_verbose'] = 'checked=yes'
count_ds = count_ds + 1
sel_speedopt_tmp = copy.deepcopy(self.selectable_speedopt)
sel_speedopt_tmp[cdsfile[i]['speed_class']-1][2] = 'selected'
cdsfile[i]['selspeed_sel'] = sel_speedopt_tmp
possibleopt=megasearch.listpossiblesearchoptions()
for slctg in possibleopt:
if(slctg[0] == genopt['search_default']):
slctg[2] = 'selected'
tnarray = []
for ntn in xrange(1,50):
if(genopt['trends_qty'] == ntn):
tnarray.append([ ntn, ntn,'selected'])
else:
tnarray.append([ntn, ntn,''])
genopt['general_https_verbose'] = ''
genopt['general_trend_verbose'] = ''
genopt['general_suggestion_verbose'] = ''
if(genopt['general_https'] == 1):
genopt['general_https_verbose'] = 'checked=yes'
if(genopt['general_suggestion'] == 1):
genopt['general_suggestion_verbose'] = 'checked=yes'
if(genopt['general_trend'] == 1):
genopt['general_trend_verbose'] = 'checked=yes'
#.........这里部分代码省略.........
示例7: check
# 需要导入模块: import SearchModule [as 别名]
# 或者: from SearchModule import loadSearchModules [as 别名]
def check(self, args):
ret = 0
if (('hostname' in args) and ('type' in args)):
# Perform the search using every module
global globalResults
if 'loadedModules' not in globals():
SearchModule.loadSearchModules()
# ~ specials
if (args['type'] == 'OMG'):
ret = 1
cfg_tmp = {'valid': 1,
'type': 'OMG',
'speed_class': 2,
'extra_class': 0,
'login': args['user'],
'pwd': args['pwd'],
'timeout': self.cgen['timeout_class'][2],
'builtin': 1}
for module in SearchModule.loadedModules:
if (module.typesrch == 'OMG'):
module.search('Ubuntu', cfg_tmp)
print cfg_tmp['retcode']
if (cfg_tmp['retcode'][0] != 200):
ret = 0
# ~ server based API
if (args['type'] == 'NAB'):
ret = 1
cfg_tmp = {'url': args['hostname'],
'type': 'NAB',
'api': args['api'],
'speed_class': 2,
'extra_class': 0,
'valid': 1,
'timeout': self.cgen['timeout_class'][2],
'builtin': 0}
for module in SearchModule.loadedModules:
if (module.typesrch == 'NAB'):
module.search('Ubuntu', cfg_tmp)
print cfg_tmp['retcode']
if (cfg_tmp['retcode'][0] != 200):
ret = 0
# ~ server based WEB
if (args['type'] == 'DSN' or args['type'] == 'DS_GNG'):
cfg_deep_tmp = [{'url': args['hostname'],
'user': args['user'],
'pwd': args['pwd'],
'type': args['type'],
'speed_class': 2,
'extra_class': 0,
'valid': 1,
}]
ds_tmp = DeepsearchModule.DeepSearch(cfg_deep_tmp, self.cgen)
ret_bool = ds_tmp.ds[0].search('Ubuntu')
if (ret_bool):
ret = 1
else:
ret = 0
return ret