示例#1
0
	def create_a_job(self, sess):
		new_action = action(ACTIONID = "BASICJOB", CMDLINE = QUICK_CMD, USERID = self.new_user.USERID)
		sess.add(new_action)
		sess.flush()
		new_job = job(ACTIONID = "BASICJOB", SCHEDID = "ONCE", status = 0)
		sess.add(new_job)
		sess.flush()
		q = sess.query(job).filter(job.ACTIONID == "BASICJOB").all()
		a = sess.query(action).filter(action.ACTIONID == "BASICJOB").first()
		return q
示例#2
0
async def process_coro(in_queue, out_queue, seconds):
    print('process_coro() started')
    while True:
        print('process_coro() running')
        # wait for the input queue
        msg = await in_queue.get()
        print('process_coro() got message from queue')
        # create job from the message
        newJob = job(msg)
        # put job in the output queue
        await out_queue.put(newJob)
        print('process_coro() put job in queue: {}'.format(newJob.cmd))
        # allow other tasks to run
        await asyncio.sleep(seconds)
示例#3
0
	def testDescription(self):
		u = user(USERID = "DAN", EMAIL="*****@*****.**")
		edef = eventdef()
		desc = edef.event_text("%USER% has email %EMAIL%", event_user = u)
		self.assert_(u.USERID in desc)
		self.assert_(u.EMAIL in desc)

		s = server(SERVERID = "testserver", IP = "192.168.1.1", PORT = 2200, OS = 1, TYPE = 1)
		desc = edef.event_text("%SERVER% has ip %IP% port %PORT% os %SERVEROS% ", event_server = s, event_user = u)
		self.assert_(s.SERVERID in desc)
		self.assert_(s.IP in desc)
		self.assert_(str(s.PORT) in desc)
		self.assert_(s.os_to_string() in desc)

		q = job(JOBID = 14, SCHDATE = datetime.now(), BATCH = "batch1", IGNOREDEP = False, REMAININGRUNS = 15, MAXRUNS = 10)
		desc = edef.event_text("%JOB% %SCHDATE% %BATCH% %IGNOREDEPS% %REMAININGRUNS% %MAXRUNS%", event_job = q)
		self.assert_(str(q.JOBID) in desc)
		self.assert_(str(q.SCHDATE) in desc)
		self.assert_(q.BATCH in desc)
		self.assert_(str(q.IGNOREDEP) in desc)
		self.assert_(str(q.REMAININGRUNS) in desc)
		self.assert_(str(q.MAXRUNS) in desc)

		a = action(ACTIONID = "Action12", CMDLINE = "dir", STDIN = True, STARTINDIR = "/etc", STDOUT = False, OS = 1, USERID = "JOHN")
		desc = edef.event_text(" %ACTION% %CMDLINE% %STDIN% %STARTINDIR% %CAPTURESTDOUT% %ACTIONOS% %ACTIONUSER%", event_action = a)
		self.assert_(a.CMDLINE in desc)
		self.assert_(a.ACTIONID in desc)
		self.assert_(str(a.STDIN) in desc)
		self.assert_(a.STARTINDIR in desc)
		self.assert_(str(a.STDOUT) in desc)
		self.assert_(a.os_to_string() in desc)
		self.assert_(a.USERID in desc)

		s = schedule(SCHEDID = "sched1", INTERVAL = 1, METHOD = 2, AFTER = 0, DELTA = 3, CALID = "cal3", CALTYPE = 2)
		desc = edef.event_text("%SCHEDID% %INTERVAL% %METHOD% %RESCHEDULEON% %DELTA% %CALENDAR% %CALTYPE% %ASCHEDULEMAXRUNS% %ABSRESCHEDULE%", event_schedule = s)
		self.assert_(s.SCHEDID in desc)
		self.assert_(str(s.INTERVAL) in desc)
		self.assert_(s.method_str() in desc)
		self.assert_(s.resch_str() in desc)
		self.assert_(s.type_str() in desc)
		self.assert_(s.CALID in desc)
		self.assert_(s.caltype_str() in desc)
		self.assert_(str(s.MAXRUNS) in desc)
		self.assert_(str(s.WHEN) in desc)

		desc = edef.event_text("%CONTROLLER% for %MESSAGE%", event_message="A generic message")
		self.assert_(myname in desc)
		self.assert_("A generic message" in desc)
示例#4
0
    def scrape(self):
        """ scrape job information from the current page """
        self.wait.until(EC.presence_of_element_located((By.ID, 'vjs-desc')))
        content = self.driver.page_source
        soup = BeautifulSoup(content, 'lxml').find(id='vjs-container')
        parseTopCard = self.parseTopCard(soup)
        parseJobDetails = self.parseJobDetails(soup)

        self.id += 1
        key = "Indeed-{date}[{id:03d}]".format(
            date=datetime.date.today().strftime("%Y-%m-%d"), id=self.id)
        JOB = job(parseTopCard['Job Title'], parseTopCard['url'],
                  parseTopCard['Company Name'],
                  parseTopCard['Company Location'], parseTopCard['Post Date'],
                  '', '', '', '', parseJobDetails[0], parseJobDetails[1],
                  parseJobDetails[2])
        self.job_list.addJob(key, JOB)
        sleep(4)
示例#5
0
    def scrape(self):
        """ scrape job information from the current page """
        try:
            view_more = self.driver.find_element_by_css_selector(
                'button[class*="view-more-icon"]').text.split('\n')[1]
            while view_more != 'View less':
                self.driver.find_element_by_css_selector(
                    'button[class="view-more-icon"]').click()
                view_more = self.driver.find_element_by_css_selector(
                    'button[class*="view-more-icon"]').text.split('\n')[1]
        except NoSuchElementException:
            return

        sleep(2)
        content = self.driver.page_source
        soup = BeautifulSoup(content, 'lxml')
        parseTopCard = self.parseTopCard(soup)
        parseJobDetails = self.parseJobDetails(soup)

        print('Got: {}'.format(parseTopCard.get('Job Title')))

        try:
            parseJobDescriptionDetails = self.parseJobDescriptionDetails(soup)
        except Exception:
            parseJobDescriptionDetails = {}

        if parseTopCard:
            self.id += 1
            key = "Linkedin-{date}[{id:03d}]".format(
                date=datetime.date.today().strftime("%Y-%m-%d"), id=self.id)
            JOB = job(parseTopCard['Job Title'], parseTopCard['url'],
                      parseTopCard['Company Name'],
                      parseTopCard['Company Location'],
                      parseTopCard['Post Date'],
                      parseJobDescriptionDetails.get('Seniority Level'),
                      parseJobDescriptionDetails.get('Industry'),
                      parseJobDescriptionDetails.get('Employment Type'),
                      parseJobDescriptionDetails.get('Job Functions'),
                      parseJobDetails[0], parseJobDetails[1],
                      parseJobDetails[2])
            self.job_list.addJob(key, JOB)
        sleep(4)
	def activate(self):
		sess = getsession()
		j = job(ACTIONID = self.ACTIONID, SCHEDID = "ONCE")
		sess.add(j)
		sess.flush()
示例#7
0
	def testQuickCreate(self):
		quick_create_event(1, event_server = server(SERVERID = "TEST"), event_schedule=schedule(SCHEDID = "SCHED1"), event_job=job(JOBID = 15), event_action=action(ACTIONID="ACT1"), event_user=user(USERID="Dan"))
		self.assert_(getsession().query(event).filter(event.EVENTNUM == 1).count())
		e = getsession().query(event).filter(event.EVENTNUM == 1).one()
		self.assert_(e.SERVERID == "TEST")
		self.assert_(e.SCHEDID == "SCHED1")
		self.assert_(e.JOBID == 15)
		self.assert_(e.ACTIONID == "ACT1")
		self.assert_(e.USERID == "Dan")
示例#8
0
def load_config_files(flush=False):
	_f = open(os.path.join('data','config_files.txt'),'r')
	_flist = _f.readlines()
	_f.close()
	
	try:
		_f = open(os.path.join('data','hashes.txt'),'r')
	except:
		_f = open(os.path.join('data','hashes.txt'),'w')
		_f.write('')
		_f.close()
		_f = open(os.path.join('data','hashes.txt'),'r')
	
	_fhashes = _f.readlines()
	_f.close()
	
	_newhashes = []
	for file in _flist:
		
		file = file[:len(file)-1]+'.xml'
		_t = open(os.path.join('data',file),'r')
		_newhashes.append((file,hashlib.md5(_t.read()).hexdigest()))
		_t.close()
	
	_hashes = []
	for hash in _fhashes:
		if flush:
			_h = hash[:len(hash)-1]+'derp'
		else:
			_h = hash[:len(hash)-1]
		_hashes.append(tuple(_h.split(',')))
	
	aa = set(_newhashes)
	bb = set(_hashes)
	
	if aa.difference(bb):
		if var.debug: print 'CONVERTAN'
		for file in aa.difference(bb):
			_ret = xml2json.parse(os.path.join('data',file[0]),debug=True)
			
			for i in range(0,len(_hashes)):
				if _hashes[i][0] == file[0]:
					_hashes[i] = file
		
		_f = open(os.path.join('data','hashes.txt'),'w')
		for file in _hashes:
			_f.write('%s,%s\n' % (file[0],file[1]))
		_f.close()
	
	for file in _flist:
		file = file[:len(file)-1]
		if var.debug: print 'Loading '+file
		try:
			_f = open(os.path.join('data',file+'.json'))
		except:
			print 'ERROR: Some of your .JSON files are broken.\n'
			print 'This could happen if you haven\'t compiled your .XML files yet.'
			print 'Run: ./main.py recompile'
			sys.exit()
		
		
		for line in _f.readlines():
			_j = json.loads(line)
			
			for _key in _j.iterkeys():
				key = _key
				break

			if file == 'descriptions':
				if key.count('interior'):
					global interior_descriptions
					interior_descriptions.append({'type':key[len('interior-'):],'desc':_j[key]})
				elif key.count('outside'):
					global outside_descriptions
					outside_descriptions.append({'type':key[len('outside-'):],'desc':_j[key]})
			
			elif file == 'phrases':
				global phrases
				phrases.append({'type':key,'text':_j[key]})
			
			elif file == 'names':
				if key == 'male':
					global human_male_fnames
					human_male_fnames = _j[key].split(',')
				elif key == 'female':
					global human_female_fnames
					human_female_fnames = _j[key].split(',')
				elif key == 'last':
					global human_lnames
					human_lnames = _j[key].split(',')
			
			elif file == 'jobs':
				_i = jobs.job(_j['name'])
				_i.strength_needed = int(_j['strength'])
				_i.dexterity_needed = int(_j['dexterity'])
				_i.intelligence_needed = int(_j['intelligence'])
			
			elif file == 'items':
				if _j['type'] == 'light':
					_i = items.light()
					_i.icon = _j['icon']
				elif _j['type'] == 'table':
					_i = items.table()
					_i.icon = _j['icon']
				elif _j['type'] == 'foliage':
					_i = items.foliage()
					_i.icon = 'b'
				elif _j['type'] == 'window':
					_i = items.window()
					_i.icon = ':'
				elif _j['type'] == 'weapon':
					_i = items.weapon()
					_i.category = _j['category']
					_i.attack = int(_j['attack'])
					_i.icon = 'S'	
				elif _j['type'] == 'clothing':
					_i = items.clothing()
					_i.slot = _j['slot']
					_i.defense = int(_j['defense'])
				elif _j['type'] == 'potion':
					_i = items.potion()
					_i.effect = _j['effect']
					_i.amount = int(_j['amount'])
					_i.icon = '!'
					
				_i.name = _j['ref']
				_i.action = _j['action']
				_i.room_description = _j['room_desc']
				_i.description = _j['desc']
				_i.weight = int(_j['weight'])
				_i.stat['price'] = int(_j['price'])
		
		_f.close()