Ejemplo n.º 1
0
	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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
    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 = []
        if (self.cfg is not None):
            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)
Ejemplo n.º 4
0
    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 = '******'
                flogin_caption_pwd = 'pwd'
                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
                    #~ 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,
                    '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']
                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': '******',
                    'flogin_caption_pwd': 'pwd',
                    'speed_class': speed_cl,
                    'type': dsearchmodule['opts']['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
        cdsfile_toshow1 = []
        for i in xrange(len(cdsfile)):
            if (cdsfile[i]['type'] == 'DSN'):
                cdsfile_toshow = copy.deepcopy(cdsfile[i])
                cdsfile_toshow['idx'] = count_ds
                cdsfile_toshow['valid_verbose'] = ''
                if (cdsfile_toshow['valid'] == 1):
                    cdsfile_toshow['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_toshow['selspeed_sel'] = sel_speedopt_tmp
                cdsfile_toshow1.append(cdsfile_toshow)

        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'] = ''
        genopt['smartsearch_verbose'] = ''
        genopt['max_cache_verbose'] = ''
        genopt['predb_active_verbose'] = ''
        if (genopt['predb_active'] == 1):
            genopt['predb_active_verbose'] = 'checked=yes'
        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'
        if (genopt['smartsearch'] == 1):
            genopt['smartsearch_verbose'] = 'checked=yes'
        if (genopt['cache_active'] == 1):
            genopt['cache_active_verbose'] = 'checked=yes'
        genopt['general_ipaddress_verbose'] = 'AUTO'
        if (genopt['general_ipaddress'] != ''):
            genopt['general_ipaddress_verbose'] = genopt['general_ipaddress']

        openshift_install = False
        if (len(self.dirconf)):
            openshift_install = True
        return render_template('config.html',
                               cfg=cffile,
                               cfg_dp=cdsfile_toshow1,
                               cnt=count,
                               cnt_ds=count_ds,
                               genopt=genopt,
                               selectable_opt=possibleopt,
                               sel_speedopt_basic=sel_speedopt_basic,
                               openshift_install=openshift_install,
                               tnarray=tnarray,
                               cdomainname=cdomainname,
                               cnt_max=MAX_PROVIDER_NUMBER,
                               cfg_bi=cffileb)
Ejemplo n.º 5
0
    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'

        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):
                fresponse.headers["Content-Disposition"] = response.info(
                ).headers[i][riff +
                             21:len(response.info().headers[i])].strip()
        return fresponse
Ejemplo n.º 6
0
    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 = '******'
                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': '******',
                          'flogin_caption_pwd': 'pwd',
                          'speed_class': speed_cl,
                          'extra_class': extra_cl,
                          'type': dsearchmodule['opts']['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'
                sel_extraopt_tmp = copy.deepcopy(self.selectable_extraopt)
                sel_extraopt_tmp[cffile[i]['extra_class']][2] = 'selected'
                cffile[i]['selspeed_sel'] = sel_speedopt_tmp
                cffile[i]['selextra_sel'] = sel_extraopt_tmp

        sel_speedopt_basic = copy.deepcopy(self.selectable_speedopt)
        sel_speedopt_basic[0][2] = 'selected'
        sel_extraopt_basic = copy.deepcopy(self.selectable_extraopt)
        sel_extraopt_basic[0][2] = 'selected'

        count_ds = 0
        cdsfile_toshow1 = []
        for i in xrange(len(cdsfile)):
            if (cdsfile[i]['type'] == 'DSN'):
                cdsfile_toshow = copy.deepcopy(cdsfile[i])
                cdsfile_toshow['idx'] = count_ds
                cdsfile_toshow['valid_verbose'] = ''
                if (cdsfile_toshow['valid'] == 1):
                    cdsfile_toshow['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'

                sel_extraopt_tmp = copy.deepcopy(self.selectable_extraopt)
                sel_extraopt_tmp[cdsfile[i]['extra_class']][2] = 'selected'

                cdsfile_toshow['selspeed_sel'] = sel_speedopt_tmp
                cdsfile_toshow['selextra_sel'] = sel_extraopt_tmp
                cdsfile_toshow1.append(cdsfile_toshow)

        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'] = ''
        genopt['smartsearch_verbose'] = ''
        genopt['max_cache_verbose'] = ''
        genopt['predb_active_verbose'] = ''
        genopt['general_restrictopt1_verbose'] = ''
        genopt['general_dereferer_verbose'] = ''
        if (genopt['predb_active'] == 1):
            genopt['predb_active_verbose'] = 'checked=yes'
        if (genopt['general_https'] == 1):
            genopt['general_https_verbose'] = 'checked=yes'
        if (genopt['general_restrictopt1'] == 1):
            genopt['general_restrictopt1_verbose'] = 'checked=yes'
        if (genopt['general_dereferer'] == 1):
            genopt['general_dereferer_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'
        if (genopt['smartsearch'] == 1):
            genopt['smartsearch_verbose'] = 'checked=yes'
        if (genopt['use_warp'] == 1):
            genopt['use_warp_verbose'] = 'checked=yes'
        if (genopt['cache_active'] == 1):
            genopt['cache_active_verbose'] = 'checked=yes'
        genopt['general_ipaddress_verbose'] = 'AUTO'
        if (genopt['general_ipaddress'] != ''):
            genopt['general_ipaddress_verbose'] = genopt['general_ipaddress']

        openshift_install = False
        if (len(self.dirconf_oshift)):
            openshift_install = True
        return render_template('config.html', cfg=cffile, cfg_dp=cdsfile_toshow1, cnt=count, cnt_ds=count_ds,
                               genopt=genopt,
                               selectable_opt=possibleopt,
                               sel_speedopt_basic=sel_speedopt_basic,
                               sel_extraopt_basic=sel_extraopt_basic,
                               openshift_install=openshift_install,
                               tnarray=tnarray,
                               cdomainname=cdomainname,
                               cnt_max=MAX_PROVIDER_NUMBER, cfg_bi=cffileb)
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
    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
Ejemplo n.º 9
0
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()
Ejemplo n.º 10
0
	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'

		openshift_install = False
		if(len(self.dirconf)):
			openshift_install = True
		return render_template('config.html', cfg=cffile, cfg_dp=cdsfile,  cnt=count,  cnt_ds=count_ds, genopt = genopt, 
												selectable_opt = possibleopt,
											  sel_speedopt_basic = sel_speedopt_basic,
											  openshift_install = openshift_install,
											  tnarray = tnarray,
 											  cnt_max=MAX_PROVIDER_NUMBER, cfg_bi=cffileb)
Ejemplo n.º 11
0
    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
Ejemplo n.º 12
0
certdir = SearchModule.resource_path('certificates/')
log = logging.getLogger()
handler = logging.handlers.RotatingFileHandler(
    logsdir + 'nzbmegasearch.log',
    maxBytes=cfgsets.cgen['log_size'],
    backupCount=cfgsets.cgen['log_backupcount'])
log.setLevel(logging.INFO)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
log.addHandler(handler)
log.info(motd)
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)
Ejemplo n.º 13
0
    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'

        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'

        openshift_install = False
        if (len(self.dirconf)):
            openshift_install = True
        return render_template('config.html',
                               cfg=cffile,
                               cfg_dp=cdsfile,
                               cnt=count,
                               cnt_ds=count_ds,
                               genopt=genopt,
                               selectable_opt=possibleopt,
                               sel_speedopt_basic=sel_speedopt_basic,
                               openshift_install=openshift_install,
                               cnt_max=MAX_PROVIDER_NUMBER,
                               cfg_bi=cffileb)