Exemplo n.º 1
0
 def executeThreadsStatus(self, key, thread):
     tuid = control.id_generator(16)
     try:
         title = cleantitle.title_from_key(key)
         control.AddThread('executeThreadsStatus',
                           'Provider Search Manage Thread: %s' % title,
                           time.time(), '1', False, tuid, thread)
         while thread != None and thread.isAlive():
             time.sleep(1.0)
     except Exception as e:
         log(type='ERROR-CRITICAL', err='executeThreadsStatus - %s' % e)
     control.RemoveThread(tuid)
Exemplo n.º 2
0
    def executeThreads(self, key):
        try:
            title = cleantitle.title_from_key(key)
            log(type='SUCCESS', err='Starting Threads ! : %s' % title)
            while key in self.threadSlots:
                for s in self.threadSlots[key]:
                    active = 0
                    done = 0
                    idle = 0
                    for s1 in self.threadSlots[key]:
                        if s1['status'] == 'active':
                            active += 1
                        if s1['status'] == 'idle':
                            idle += 1
                        if s1['status'] == 'done-marked':
                            log(type='SUCCESS',
                                err='Completed Thread: %s > %s in %ss.' %
                                (title, s1['source'],
                                 round(s1['e_time'] - s1['s_time'], 2)))
                            control.RemoveThread(s1['tuid'])
                            s1['status'] = 'done'
                        if s1['status'] == 'done':
                            done += 1

                    if done == len(self.threadSlots[key]):
                        log(type='SUCCESS',
                            err='Completed Threads ! : %s with %s sources' %
                            (title, len(self.sourcesFilter(key=key))))
                        control.savePermStore()
                        return

                    if s['status'] == 'idle' and active < int(
                            control.setting('control_concurrent_src_threads')):
                        log(type='SUCCESS',
                            err='Starting Thread: %s > %s' %
                            (title, s['source']))
                        s['status'] = 'active'
                        s['s_time'] = time.time()
                        tuid2 = control.id_generator(16)
                        control.AddThread(
                            'executeThreads',
                            'Provider Search Thread: %s > %s' %
                            (title, s['source']), time.time(), '4', False,
                            tuid2, s['thread'])
                        s['tuid'] = tuid2
                        s['thread'].start()

                    time.sleep(1.0)
                time.sleep(1.0)
        except Exception as e:
            log(type='ERROR-CRITICAL', err='Thread Title %s - %s' % (title, e))
        control.savePermStore()
Exemplo n.º 3
0
	def InitSleepThread(self):
		try:
			while self.init == True:
				tuid = control.id_generator(16)
				control.AddThread('%s-InitSleepThread' % self.name, 'Persists & Monitors Provider Requirements (Every 20 mins.)', time.time(), '4', True, tuid)
				log('INFO','InitSleepThread', 'Sleeping for 20 mins.')
				time.sleep(20*60)
				self.siteonline = self.testSite()
				self.testparser = self.testParser()
				self.initAndSleep()
				control.RemoveThread(tuid)
		except Exception as e:
			log('ERROR','InitSleepThread', '%s' % e)
		control.RemoveThread(tuid)
Exemplo n.º 4
0
    def initProviders(self):
        tuid = control.id_generator(16)
        control.AddThread('initProviders', 'Initialize Providers', time.time(),
                          '1', False, tuid)
        try:
            del self.providers[:]
            del self.providersCaller[:]
            del self.providerInProcess[:]

            for package, name, is_pkg in pkgutil.walk_packages(__path__):
                try:
                    self.providerInProcess.append('%s.py' % name)
                    c = __import__(name, globals(), locals(), [], -1).source()
                    log("Adding Provider %s : %s to Interface" %
                        (c.info()['name'], c.info()['url']),
                        name='providers')
                    self.providersCaller.append({
                        'name': c.info()['name'],
                        'url': c.info()['url'],
                        'call': c,
                        'types': c.type_filter
                    })
                    self.providers.append(c.info())
                    self.providersTimer[c.info()['name']] = {}
                    control.control_json[c.info()['name']] = {}
                    self.providersInit1.append(c.info()['name'])
                except Exception as e:
                    log(type='ERROR-CRITICAL',
                        err='Could not import %s > %s (Retrying)' % (name, e))
                    try:
                        c = __import__(name, globals(), locals(), [],
                                       -1).source()
                        log("Adding Provider %s : %s to Interface" %
                            (c.info()['name'], c.info()['url']),
                            name='providers')
                        self.providersCaller.append({
                            'name': c.info()['name'],
                            'url': c.info()['url'],
                            'call': c,
                            'types': c.type_filter
                        })
                        self.providers.append(c.info())
                        self.providersTimer[c.info()['name']] = {}
                        control.control_json[c.info()['name']] = {}
                    except Exception as e:
                        log(type='ERROR-CRITICAL',
                            err='Could not import %s > %s (Retrying-Failed)' %
                            (name, e))
                        error_info = {
                            'url': 'Unknown',
                            'name': "%s.py" % name,
                            'msg': "Loading Error: %s" % e,
                            'speed': 0.0,
                            'logo': 'Unknown',
                            'ssl': 'Unknown',
                            'frd': True,
                            'online': 'Unknown',
                            'online_via_proxy': 'Unknown',
                            'parser': 'Unknown'
                        }
                        self.providers.append(error_info)
                        self.providersTimer[name] = {}
                        control.control_json[name] = {}
                        self.providersInit1.append(name)
                del self.providerInProcess[:]
        except:
            pass
        self.isProvThreadRunning = False
        ret = control.loadPermStore()
        del self.providerInProcess[:]

        if ret != None:
            for k in ret.keys():
                control.control_json[k] = ret[k]
                self.providersTimer[k] = ret[k]

        log(type='INFO',
            method='init',
            err=' -- Initializing End --',
            name='sources')
        self.isInitialized = True

        control.RemoveThread(tuid)