Beispiel #1
0
Datei: ppi.py Projekt: lnxpy/ppi
def _ins_mod(_libs, _capt):
    print('Request for install ' + colors.bold + str(_libs[_capt]) +
          colors.end + ' at ' + colors.end + colors.green + str(time.now()) +
          colors.end)
    print(colors.blue + 'please wait for ' + colors.end + colors.red +
          'install ' + colors.end + colors.bold + _libs[_capt] + colors.end)
    slp(2)
    _stat = sys('pip3 install ' + _libs[_capt])
    if _stat == 0:
        print('installing ' + colors.bold + _libs[_capt] + colors.end +
              ' module has ' + colors.red + colors.bold + 'done' + colors.end)
        _save(_libs[_capt] + ' installed -- ' + str(time.now()) + '\n')
    else:
        print('We have a' + colors.bold + colors.fail + ' Problem!' +
              colors.end)
        print('1 - ' + colors.fail + 'Check You\'r connection and try again.' +
              colors.end)
        print(
            '2 - ' + colors.fail +
            'Check the Selected module in you\'r installed module\'s with <pip list> or <pip freeze> command.'
            + colors.end)
        print('3 - ' + colors.fail + 'Check the pip version. it must be 3!' +
              colors.end)
        _save('Problem for install ' + _libs[_capt] + ' -- ' +
              str(time.now()) + '\n')
Beispiel #2
0
def nexDay():
    global tiempoInit
    libM()
    fechaEjecu  =  stFcfha()
    while True:
        if (str(fechaEjecu)  ==  str(date.today())):slp(tiempoInit+7200);libM()
        else:fechaEjecu       =  date.today();stFcfha();main()
Beispiel #3
0
    def load(self):
        while True:
            try:
                bro = self.driver()
                break
            except:
                pass
            slp(self.tempo1 * self.lag)

        self.openinsta(bro)
        self.login(bro)

        while True:
            random.shuffle(self.profiles)
            page_select = self.profiles

            self.action(bro, page_select)

            for seconds in range(self.interval * self.lag + 1):
                restante = str(
                    round(((self.interval * self.lag) - seconds) / 60))
                print(self.F4 + st('%H:%M:%S') + ' ' + self.C6 +
                      '[...] Processo concluído! Recomeçando em',
                      str(round(((self.interval * self.lag) - seconds) / 60)),
                      str('minuto.' if int(restante) < 2 else 'minutos.') +
                      self.CE,
                      end='\r')
                slp(1)
Beispiel #4
0
    def __init__(self,szukaj):
        if szukaj == 'linux-auto':
            try:
                self.board = util.get_the_board(base_dir='/dev/serial/by-id/', identifier='usb-')
                for i in range(6):
                    self.board.digital[13].write(1)
                    slp(i/3)
                    self.board.digital[13].write(0)
                    slp(i/3)

            except:
                print('Coś nie tak z poszukiwaniem plytki - może nie podłączona lub to nie jest Linux?')
        else:
            try:
                self.board = Arduino(szukaj)
            except:
                print('Coś nie tak z poszukiwaniem plytki - może nie podłączona (Win/MacOS) ?')


        # wejścia cyfrowe - przyciski
        self.B01 = self.board.get_pin('d:12:i')
        self.B02 = self.board.get_pin('d:11:i')
        self.B03 = self.board.get_pin('d:10:i')
        # wyjścia cyfrowe
        self.L13 = self.board.get_pin('d:13:o')
        self.PWM = self.board.get_pin('d:9:p')
        self.L_R = self.board.get_pin('d:8:o')
        self.L_Y = self.board.get_pin('d:7:o')
        self.L_G = self.board.get_pin('d:2:o')
        self.P_R = self.board.get_pin('d:5:p') # sprawdzić !!!!
        self.P_G = self.board.get_pin('d:3:p')
        self.P_B = self.board.get_pin('d:6:p')
        self.BUZ = self.board.get_pin('d:4:o')
	def begin(self):
		sorts = ['sort=date', '']
		keywords_done_idx = self.index
		#keywords_done_idx = self.r_master.get(self.country_code) #--this over here should talk to master's redis
		print 'starting from %s' % str(keywords_done_idx)
		if not keywords_done_idx:
			keywords_done_idx = -1
		else:
			keywords_done_idx = int(keywords_done_idx)
		
		for i, keyword in enumerate(self.keywords):
			keyword = keyword.replace('\n', '')
			if i <= keywords_done_idx:
				continue
			else:
				print 'now working on..%d in begin..' % i 
				for sort in sorts:
					self.resource_collection(i, keyword, sort)
				#--checking the block
				if sum(map(lambda p: p[1], self.time_all[-2:])) == 0 and len(self.time_all) > 2:
					check = self.get_static_resource(self.fixed_test_url)
					if not len(check):
						print 'putting to sleep for 10 mins because last 4 keywords went nill and check indicated block..'
						print 'currently worked at .. %d' % i
						slp(1200)

				#self.r_master.set(self.country_code, i)
		#self.send_to_master()
		#self.r_master.hset('droplets', socket.gethostname(),  True)
		#print 'sent db to master...terminating..'
		self.keywords.close()
		sys.exit()
		return
	def get_resource(self, url_):
		user_agent = self.user_agents_cycle.next()
		try:
			resp = requests.get(url_, headers = {'user_agent': user_agent})
		except:
			slp(100)
			print 'sleeping for 100 secs due to a block..'
			user_agent = self.user_agents_cycle.next()
			resp = requests.get(url_, headers = {'user_agent': user_agent})

		if resp.status_code == 200:
			data = pq_(resp.text)
			data = data('#resume_body').children()
			if not data:
				user_agent = self.user_agents_cycle.next()
				resp = requests.get(url_, headers = {'user_agent': user_agent})
				if resp.status_code == 200:
					data = pq_(resp.text)
					data = data('#resume_body').children()
					return data
				else:
					return []
			else:
				return data
		else:
			return []
Beispiel #7
0
	def runInVT(it, cmd, envm=None, stdin=PIPE):
		from subprocess import Popen as ppn, STDOUT
		from shlex import split as shs
		from os import setsid
		from psutil import Process as pss
		if envm is None:
			from os import environ as env
			envm = env.copy()
		# drop run if busy by previous task
		if type(it.proc) is ppn and(it.proc.poll()== None):
			return False
		it.proc = ppn(shs(cmd),
			env=envm,
			#stdin=it.fifo_in_fn,
			stdin=stdin,
			stdout=it.pty_child_fd,
			stderr=STDOUT, preexec_fn=setsid)
		it.proc.children = None
		try:
			p = pss(it.proc.pid)
			it.proc.children = p.get_children(recursive=True)
		except:
			pass
		#it.std_reply = open(it.fifo_in_fn, 'wb')
		while it.proc.poll()==None: # poll()==None means still running
			slp(.5)
		#it.std_reply.close()
		it.proc = None
		return True
	def get_resource(self, url_):
		user_agent = self.user_agents_cycle.next()

		#--add some more solid step here, as in the except when the max retries error occurs, the script breaks
		try:
			resp = requests.get(url_, headers = {'user_agent': user_agent})
		except:
			slp(300)
			print 'sleeping for 300 secs due to a block..'
			user_agent = self.user_agents_cycle.next()
			resp = requests.get(url_, headers = {'user_agent': user_agent})

		if resp.status_code == 200:
			data = pq_(resp.text)
			data = data('#results').children()
			if not data:
				user_agent = self.user_agents_cycle.next()
				resp = requests.get(url_, headers = {'user_agent': user_agent})
				if resp.status_code == 200:
					data = pq_(resp.text)
					data = data('#results').children()
					return data
				else:
					return []
			else:
				return data
		else:
			return []
Beispiel #9
0
def mainDos():
    libM()
    global today,tiempoInit,tiempoErr,archivoU0Z,archivoS1,Rs1,Ru0z
    slp(tiempoInit)
    
    try:
        enviado  =  False
        if (activarIntTFHKA()):
            logger.info('impresora conectada satfactoriamente ')
            if (cwU0Z() and cwS1()):
                logger.info('Archivo U0Z y S1 creado satifactoriamente')
                if (copiaCCS1() and copiaCCU0Z()):
                    logger.info('Archivo U0Z y S1 copiado a la carpeta compartida satifactoriamente')
                    enviado  =  True
                    rm(Rs1)
                    rm(Ru0z)
                else:
                    enviado  =  False
                    logger.warning("Error al escribir U0Z y S1")
            else:logger.warning("Error al escribir U0Z y S1")

        else:
            for i in range(reIntento):
                if activarIntTFHKA():mainDos()
                else:logger.warning("Error de impresora verifique conecion inento "+str(i));slp(tiempoErr)


    except Exception as e:
        global infoERR
        if infoERR == True:
            logger.warning(formErro)
        logger.warning(str(e))
    return enviado
Beispiel #10
0
 def add(self, bro, page_select):
     pages = page_select[0:20]
     added = 1
     for page in pages:
         try:
             bro.get('https://www.instagram.com/' + page + '/')
             slp(self.tempo3 * self.lag)
             bro.find_elements_by_xpath("//div[@class='_e3il2']")[0].click()
             slp(self.tempo2 * self.lag)
             try:
                 bro.find_elements_by_xpath(
                     "//a[@class='_nzn1h _gu6vm']")[0].click()
             except:
                 bro.find_elements_by_xpath(
                     "//a[@class='_nzn1h']")[0].click()
             slp(self.tempo2 * self.lag)
             users = bro.find_elements_by_xpath(
                 "//button[@class='_qv64e _gexxb _4tgw8 _njrw0']")
             slp(self.tempo2 * self.lag)
             random.shuffle(users)
             for user in users:
                 user.click()
                 slp(random.randrange(1, 4))
                 print(self.F1 + st('%H:%M:%S') + self.CE + '[' +
                       str(added) + ']' + self.C4 +
                       '[+] Adicionando usuários...',
                       end='\r')
                 added += 1
         except Exception as add_err:
             print('\nAdicionados:', str(added))
             return
     print('\nAdicionados:', str(added))
Beispiel #11
0
def grup():
      global token 
      print (lc+'\nTUNGGU SEBENTAR EA :*'+x) 
      print (lc+'**********************************'+x)
      try:
            r = requests.get('https://graph.facebook.com/me/groups?access_token='+token)
      except:
            print (lr+'Masalah pada Jaringan/Token !'+x)
            print (a+'Tips: Nyalakan data internet \ndan cek token kembali.\n'+x)
            input(lg+'Press enter to back to menu'+x)
            home()
      result = json.loads(r.text)
      a = open('id/id.txt','w')
      try:
            for grup in result['data']:
                  a.write('Nama : '+grup['name']+'\nID   : '+grup['id']+'\n\n')
                  slp(0.05)
                  print (lc+'Nama = '+x,grup['name'],lc+'\nID   = '+x,grup['id'])
                  print (lc+'**********************************'+x)
      except KeyError:
            print(lr+'Masalah pada token !'+x)
            input(lb+'Press enter to back to menu'+x)
      a.close()
      input(lb+'Press enter to back to menu'+x)
      return token
Beispiel #12
0
def conexionFTP():
    print "conexionFTP"
    global reIntento, rutaFtp,tiempoErr,hostFtp,passFtp,userFtp,portFtp,infoERR
    #request = urllib.request.Request('http://'+hostFtp)
    #response = urllib.request.urlopen(request)
    estatusCftp=False
    if response.getcode() == 200:
        try:

            ftp = FTP_TLS()
            ftp.connect(hostFtp,portFtp)
            ftp.login(userFtp, passFtp)
            ftp.cwd(rutaFtp)

            estatusCftp = True

        except Exception as e:
            if infoERR == True:logger.warning(formErro)
            logger.warning('Error al conectar al servidor ftp '+str(e))
    else:
        logger.warning('Error al conectar al servidor Error de internet '+str(e))
        for i in range(reIntento):
            if conexionFTP()['ftp']:main()
            else:logger.warning("reconecion internet intento  "+str(i));slp(tiempoErr)#
    return {'ftp':ftp,'estatusCftp':estatusCftp}
Beispiel #13
0
def robot_read(base_url):
    '''
        Look for time out and disallowed urls on robots.txt
            Defaults to a timeout of 2.5, and everything allowed

        Arguments:
            base_url :: the base url off of which to find robots.txt

        Returns:
            t_out    :: The time out length on which to wait
            disallow :: The urls that are disallowed
    '''
    t_out, disallow = 2, set()
    html = goto('/'.join(base_url.split('/') + ["robots.txt"]))
    try:
        for line in html.split('\n'):
            if "Crawl-delay:" == line[:12]:
                t_out = int(line[12:])
            elif "Disallow" in line and "#" not in line:
                disallow.add(
                    validate_url(base_url,
                                 line.strip("^M \n").split(" ")[-1]))
        log.info("Robots.txt found. Setting timeout to {}".format(t_out))
        log.info("Disallowing : {}".format(" ".join(disallow)))
    except AttributeError:
        t_out = 3  # Big site means actual pages instead of pure 404s
    print("The time for sleep is: ", t_out)
    slp(t_out)
    return t_out, disallow
Beispiel #14
0
        def countDown():
            mySeconds = Timer.entry.get()
            mySeconds = mySeconds if mySeconds else 0  # Checks if there is no input
            timeleft = StringVar()

            self.label.destroy()
            self.entry.destroy()
            self.button.destroy()
            self.label3 = Label(self, text="Time Remaining:")
            self.label4 = Label(self, textvariable=timeleft)
            self.label3.pack(side="top", pady=25)
            self.label4.pack(side="top")

            # for each second from mySeconds until -1
            for t in range(int(mySeconds), 0, -1):
                # formatted as two digit numbers with zeros as fill
                # divmod() gives minutes, seconds and then hours, minutes
                m, s = divmod(t, 60)
                h, m = divmod(m, 60)
                timeleft.set("%02d:%02d:%02d" % (h, m, s))
                self.update()
                slp(1)

            self.label3.destroy()
            self.label4.destroy()
            self.label2.pack(side=TOP, pady=20)
            self.button2.pack(side=BOTTOM, pady=0)  ## pady5
Beispiel #15
0
Datei: ppi.py Projekt: lnxpy/ppi
def _ins_pip3():
    print('Request for install ' + colors.bold + 'python3-pip ' + colors.end +
          'at ' + colors.end + colors.green + str(time.now()) + colors.end)
    print(colors.blue + 'please wait for ' + colors.end + colors.red +
          'install ' + colors.end + colors.bold + 'python3-pip' + colors.end)
    slp(2)
    sys('sudo apt install python3-pip')
    _save('Python3-pip installed -- ' + time.now() + '\n')
Beispiel #16
0
def FifthScreen():
    HUD()
    slp(1)
    global morale
    global soldiers
    global date
    global ruler
    global gold
    global farmer_second
def modoTres():
    global tiempoErr, reIntento
    if mainTres():
        logger.info('Ejcucion exitoxa! modo 3')
        nexDay()
    else:
        slp(tiempoErr)
        logger.warning('Error en jecucion en systema intento ')
        modoTres()
Beispiel #18
0
    def run(self):
        while True:
            self.event.wait()  # set->clear

            if not self._kill:
                break

            self._task(*self._task_args, **self._task_kwargs)
            slp(.1)
Beispiel #19
0
def modoUno():
    global reIntento,tiempoErr
    if mainUno():        
        logger.info('Ejcucion exitoxa modo 1!')
        nexDay()
    else:
        slp(tiempoErr)
        logger.warning('Error en jecucion en systema ')
        nexDay()
Beispiel #20
0
    def passive(self):
        def upt_activity():
            timeNow = int(time.time())
            timeEnd = timeNow + 300
            try:
                self.send_active_obj(startTime=timeNow, endTime=timeEnd)
            except Exception as activeError:
                pass

        def change_bio_and_welcome_members():
            if self.welcome_chat or self.message_bvn:
                Thread(target=self.welcome_new_member).start()
            try:
                self.activity_status('on')
                if isinstance(self.bio_contents, list):
                    self.edit_profile(content=choice(self.bio_contents))

                elif isinstance(self.bio_contents, str):
                    self.edit_profile(content=self.bio_contents)

            except Exception as e:
                print_exception(e)

        def feature_chats():
            try:
                Thread(target=self.feature_chats).start()
            except Exception as e:
                print_exception(e)

        def feature_users():
            try:
                Thread(target=self.feature_users).start()
            except Exception as e:
                print_exception(e)

        feature_chats()
        feature_users()

        j = 0
        k = 0
        while self.marche:
            change_bio_and_welcome_members()
            if j >= 240:
                feature_chats()
                j = 0
            if k >= 2880:
                feature_users()
                k = 0

            if self.activity:
                upt_activity()

            slp(30)
            j += 1
            k += 1
	def resource_collection(self, keyword_index, keyword, sort, rest_kewords=False):
		start_time = tm()
		n_all = 0
		n_profiles = {}
		keyword = '%s' % keyword.replace('/', ' ')
		keyword = keyword.strip('\n')
		init_url = self.init_url % (keyword.replace(' ', '+'), 0, 50)
		
		filtering_urls, result_count  = self.get_filter_urls(init_url, 0)
		
		if result_count >= 1000:
			counter = 10
		else:
			counter = int(max(float(result_count)/100, 1))
		
		for route in filtering_urls:
			url_ = self.url_ % pq_(route).children('a').attr('href')
			for i in range(counter):
				if i == 0:
					beg = i
					end = i+100
				else:
					beg = end
					end = end+100
				postfix = '&start=%d&limit=%d&radius=100&%s&co=%s' % (beg, end, sort, self.country_code)	
				print url_+postfix	
				data = self.get_resource(url_+postfix, 0)

				for each in data:
					item = pq_(each)
					unique_id = item.attr('id')
					city_ = item('.location').text()
					n_profiles[unique_id] = city_
					profile_data = indeed_resumes_details(unique_id).resource_collection()
					self.save_to_disk(profile_data, unique_id)
					n_all += 1

			db_success = False
			while not db_success:
				try:
					db_insert_hash(n_profiles, self.country_code)
					db_success = True
				except:
					print 'db locked..will wait for 5 secs and try again..'
					slp(5)
					pass
			print 'inserted %d records to db.. %s, %d' % (len(n_profiles), keyword, keyword_index)	
			n_profiles = {}
			slp(0) #--sleeping for 2 secs for every filter for not making calls too fast and get blocked quickly
			gc.collect()
		gc.collect()
		current_time = tm()
		self.time_all.append((keyword, n_all, current_time - start_time))
		print 'current time passed..%d secs for one round of %s (%d)' % (int(current_time - begin_time), keyword, keyword_index)
		return
Beispiel #22
0
def send_email_to_all(latency=0):
    slp(latency)
    subscribers = Subscribers.objects.all()
    send_mail(
        'This is Title',
        'This is Body',
        '*****@*****.**',  # This is the sender email => Gets from settings.py
        [mail.email for mail in subscribers],
        fail_silently=False,
    )
    return 'I sent emails to all %s Subscribers.' % (subscribers.count())
Beispiel #23
0
def loop():
    q = input('\nModify ur array?(y/n): ')
    if q == 'y' or q == 'Y':
        print()
        return menu()
    else:
        print('\nThank you!')
        print('Exiting please wait...\n\n')
        slp(3)
        sys.exit()
        sleep
def mainUno():
    libM()
    global today, tiempoInit, tiempoErr, archivoU0Z, archivoS1, Rs1, Ru0z, reIntento
    slp(tiempoInit)

    try:
        enviado = False
        if (activarIntTFHKA()):  #si es true
            logger.info('impresora conectada satfactoriamente ')
            if (cwU0Z() and cwS1()):
                logger.info('Archivo U0Z y S1 creado satifactoriamente')
                if conexionFTP()['estatusCftp']:
                    logger.info('conexiona ftp con el servidor en sincronia ')
                    if (pubU0Z() and pubS1()):
                        #conexionFTP()['ftp'].delete(archivoU0Z)
                        #conexionFTP()['ftp'].delete(archivoS1)
                        #conexionFTP()['ftp'].retrlines('LIST')
                        conexionFTP()['ftp'].quit()
                        logger.info(
                            'archivo publicado al servidor ftp satfactoriamente '
                        )
                        rm(Rs1)
                        rm(Ru0z)

                        enviado = True

                    else:
                        enviado = False

                else:
                    for i in range(reIntento):
                        if conexionFTP()['ftp']: mainUno()
                        else:
                            logger.warning(
                                "error  con el servidor ftp intento " + str(i))
                            slp(tiempoErr)  #

            else:
                logger.warning("Error al escribir U0Z y S1")
        else:
            for i in range(reIntento):
                if activarIntTFHKA(): mainUno()
                else:
                    logger.warning(
                        "Error de impresora verifique conecion inento " +
                        str(i))

    except Exception as e:
        global infoERR
        if infoERR == True:
            logger.warning(formErro)

        logger.warning(str(e))
    return enviado
        def Start(self):
            bd_addr = "00:14:01:06:14:17"
            port = 9
            self.sock.connect((bd_addr, port))
            print('Connected')
            self.sock.settimeout(1.0)
            slp(3)
#		self.ser.open()
            self.receiveSetup()
            self.updateEnabled()
            timer.start(5)
Beispiel #26
0
 def show_online(self, comId):
     data = {
         "o": {
             "actions": ["Browsing"],
             "target": f"ndc://x{comId}/",
             "ndcId": int(comId),
             "id": "82333"
         },
         "t": 304
     }
     data = dumps(data)
     slp(2)
     self.send(data)
def Quitter():
    while True:
        choix=input('Veux-tu quitter ou recommencer une partie ? Q/R ')
        choix=Minuscule(choix)
        if choix=='r':
            return True
        elif choix=='q':
            sys('cls')
            print("\nDommage... :'('")
            slp(1.5)
            exit()
        else:
            print('Desole mais '+choix+' n\'est pas une reponse valide...')
def flower(turtle, n, length):
    turtle = t()
    angle_1 = 50
    for i in range(n):
        turtle.fd(length)
        turtle.lt(angle_1)
        turtle.fd(length)
        turtle.lt(180 - angle_1)
        turtle.fd(length)
        turtle.lt(angle_1)
        turtle.fd(length)
        turtle.rt(angle_1)
    slp(10)
    turtle.mainloop()
Beispiel #29
0
def vpedidos(a, x):
    try:
        arq = open(a, 'r')
        for linha in arq:
            op = linha.replace("\n", '').split(';')
            if op[0] == str(x):
                print("-" * 44)
                print(f"{op[0]:^11}{op[1]:^11}{op[2]:^10}{op[3]:^10}")
        print("-" * 44)
        arq.close()
    except Exception as erro:
        print(f"Erro: {erro}")
    finally:
        slp(1)
def main():
    os.system("clear")

    try:
        _INPUT = sys.argv[1]
        _INPUT = _INPUT.lower()
    except:
        print(green + "try : '--start  ===  to START it'\n" + reset)
        os._exit(0)
    if "-start" in _INPUT:
        print(_LOGO)
        print(green + "		Author:" + blue + " {" + yellow + " Mark_Tennyson" +
              cyan + " <=>" + magenta + " [email protected]" + blue +
              " }" + reset)
        print(red + "      	  	version : 1.0.2" + reset)
        _USER_ID, _USER_PASSWD = users_Details()
        _SERVER_NAME = check_SMTP_Server_Name(_USER_ID)
        _SMTP_CONNECTION = smtplib.SMTP(_SERVER_NAME, _SMTP_PORT)
        _SMTP_CONNECTION.ehlo()
        _SMTP_CONNECTION.starttls()
        try:
            _SMTP_CONNECTION.login(_USER_ID, _USER_PASSWD)
            print("\n" + green + "[SUCCESS]" + reset +
                  " You Are Successfully Logged In\n")
        except Exception as e:
            e = str(e)
            error_Printing(e)
        while True:
            print("\n" + blue + "[INFO]" + reset +
                  " Type `help` To Know More\n")
            try:
                _CMD = raw_input(cyan + "\nEnter What You Want: " + reset)
            except:
                _CMD = input(cyan + "\nEnter What You Want: " + reset)
            _CMD == _CMD.lower()

            if "logout" in _CMD or "3" in _CMD:
                print("\n" + blue + "[INFO]" + reset + "Logging Out\n")
                slp(1)
                _SMTP_CONNECTION.quit()
                os._exit(0)
            elif "help" in _CMD or "2" in _CMD:
                help_HELP()
            elif "start" in _CMD or "1" in _CMD:
                receipient_Interact_and_Send_MAIL(_SMTP_CONNECTION, _USER_ID)
            else:
                print("\n" + red + "[ERROR]" + reset + " Invalid Input")
    else:
        print(green + "try : '--start  ===  to START it'\n" + reset)
        os._exit(0)
	def get_resource(self, url_, counter):
		if counter >= self.max_recursion_depth:
			print 'max recursion depth achieved in the get_resource'
			#slp(300)
			return []
		data = []
		resp = None
		while not resp:
			try:
				user_agent = self.user_agents_cycle.next()
				resp = requests.get(url_, headers = {'user_agent': user_agent})
			except Exception, e:
				print str(e), '@@@'
				slp(10)
				pass
Beispiel #32
0
 def welcome():
     splash = [
         '+===============+', '|               |', '|    Welcome    |',
         '|      to:      |', '|    Hangman    |', '|               |',
         '+===============+'
     ]
     for text in splash:
         print(text)
         slp(.5)
     slp(1.5)
     sys('cls')
     print('Welcome to hangman. By: NeverEndingCycle.',
           end='\n\n>>> Press enter to continue.')
     pause = input()
     sys('cls')
	def get_filter_urls(self, init_url, counter):
		if counter >= self.max_recursion_depth:
			print 'max recursion depth achieved in the get_filter_urls'
			#slp(300)
			return ([], 0)
		
		filtering_urls = []
		resp = None
		while not resp:
			try:
				user_agent = self.user_agents_cycle.next()
				resp = requests.get(init_url, headers = {'user_agent': user_agent})
			except Exception, e:
				print str(e), '###'
				slp(10)
				pass
Beispiel #34
0
def _start():
    ft = input(colors.blue + '>>' + colors.end +
               ' Enter the text file Path sample ' + colors.blue +
               '(/test.txt)' + colors.end + ' ~> ')
    try:
        op = open(ft, 'r')
        _save(ft + ' Opened')
        print(colors.red + '>> ' + colors.end + _basename(ft) + colors.red +
              ' Opened!' + colors.end + '!')
        slp(2)
        _tence((op.read()).lower(), ft)
        op.close()
    except FileNotFoundError:
        _save(ft + ' didn\'t Open')
        print(colors.fail + '>>' + colors.end + ' File not ' + colors.fail +
              'exist' + colors.end + '!')
        _start()
def update(repo, source):
    printer('running the Git\n')
    #slp(2)

    for step in steps:
        os.system('git %s' % step)

    printer('Git is pulling from the cloud\n')
    slp(2)

    try:
        os.system('git pull')
    except Exception as e:
        printer('an error occurred for pulling %s' % s, 'ERROR')
        return

    printer('%s updated successfully' % repo.split('/')[1])
	def get_static_resource(self, url):
		data = []
		resp = None
		try:
			while not resp:
				try:
					user_agent = self.user_agents_cycle.next()
					resp = requests.get(url, headers = {'user_agent': user_agent})
				except Exception, e:
					print str(e), '!!!'
					slp(5)
					pass
			if resp.status_code == 200:
				data = pq_(resp.text)
				data = data('#results').children()
				return data
			else:
				return data
Beispiel #37
0
def pubCCU0Z():
    try:
        global archivoU0Z,infoERR,tiempoErr
        fileU0Z  =  str(archivoU0Z)
        file     =  open(fileU0Z,'rb')
        if (path.exists(fileU0Z)):
            if(conexionFTP()['ftp'].storbinary('STOR %s' % fileU0Z, file)):StatusPubU0Z  =  True
            else:StatusPubU0Z  =  True
            file.close()
            logger.info("U0Z publicado al ftp")
            conexionFTP()['ftp'].quit()
        else:
            slp(tiempoErr)
            pubCCU0Z()

    except Exception as e:
        if infoERR == True:logger.warning(formErro)
        logger.warning(str(e))
    return StatusPubU0Z
def scrap_profiles(load_done=False):
	done_ = {}
	done_target = 'profile_data/done_v1.json'
	t1 = tm()
	data = get_distincts()
	#folder = '/Volumes/SKILLZEQ/%s.json'
	folder = '/Users/saif/skillz_eq_samples/%s.json'
	for i, key in enumerate(data):
		if key not in done_:
			try:
				obj = indeed_resumes_details(key)
				profile = obj.resource_collection()
				profile['semantics'] = data[key]
			except:
				print 'put to sleep for 300 secs due to break..'
				slp(300)
				try:
					obj = indeed_resumes_details(key)
					profile = obj.resource_collection()
					profile['semantics'] = data[key]
				except:
					for k_ in data:
						if k_ not in done_:
							done_[k_] = 0
					df = open(done_target, 'wb')
					df.write(json.dumps(done_))
					df.close()
					print 'script terminated at %d records...data for dones in %s' % (i, done_target)

			f = open(folder % key, 'wb')
			f.write(json.dumps(profile))
			f.close()
			done_[key] = 1

			if i % 1000 == 0:
				t2 = tm()
				print '%d records saved in %d seconds..' % (i, int(t2-t1))
				
				if i == 2000:
					break
	t2 = tm()
	print 'success... %d records scrapped.. in %d mins..' % (i, int(float(t2-t1)/60))
	return
Beispiel #39
0
def copiaCCS1():
    try:
        global archivoS1,carpetaCompartida,tiempoErr
        fileS1  =  str(archivoS1)
        if (path.exists(fileS1)):
            copy(fileS1, carpetaCompartida)
            #shutil.copy(fileS1, carpetaCompartida)
            StatusPubS1  =  True
            logger.info("S1 copiado a a la carpeta compartida")
        else:
            slp(tiempoErr)
            copiaCCS1()
            StatusPubS1 =False
    except Exception as e:
        global infoERR
        if infoERR == True:
            logger.warning(formErro)

        logger.warning(str(e))
    return StatusPubS1
Beispiel #40
0
def cwS1():
    try:
        global archivoS1,Rs1
        S1_ftp  =  open(archivoS1, "a+")
        if ifExi(Rs1):
            final_de_S1_ftp = S1_ftp.tell()
            listaS1         = ['%s \n'% open(Rs1, "r+").read()]
            S1_ftp.writelines(listaS1)
            S1_ftp.seek(final_de_S1_ftp)
            estado            =  True

        S1_ftp.close()
        slp(2)
    except Exception as e:
        global infoERR
        if infoERR == True:
            logger.warning(formErro)
        estado  =  False
        logger.warning(str(e))
        S1_ftp.close()
    return estado
def save_profiles(db_file, index=False):
    increment = 200
    root = "../../data/resumes/"
    con = sql.connect(db_file)
    cur = con.cursor()

    if not index:
        begin_index = int([e[0] for e in cur.execute("select min(id) from indeed_resumes;")][0])
    else:
        begin_index = index

    print "begin index is .. %d" % begin_index

    query = "select id, indeed_id from indeed_resumes order by id asc;"
    cur.execute(query)
    n_files = 0
    for id_, indeed_id in cur:
        print id_, indeed_id, n_files
        if id_ <= begin_index:
            continue
        else:
            try:
                if n_files % increment == 0:
                    begin_index = begin_index + increment

                directory = root + "%d-%d" % (begin_index, begin_index + increment)
                if not os.path.exists(directory):
                    os.makedirs(directory)
                data = indeed_resumes_details(indeed_id).resource_collection()
                filename = "%s/%s.json" % (directory, indeed_id)
                f = open(filename, "wb")
                f.write(json.dumps(data))
                f.close()
                n_files += 1
            except Exception, e:
                print str(e)
                slp(300)
from os import system
from time import sleep as slp
print("Addition Calculator")
numList = []
whileLoop1 = 0
while whileLoop1 == 0:
    numList.append(int(input("Please type a number:")))
    system('cls')
    while True:
        nextNumber = input("Do you want to type another number:")
        if nextNumber == "yes" or nextNumber == "Yes" or nextNumber == "YES" or nextNumber == "yEs" or nextNumber == "yeS" or nextNumber == "yES" or nextNumber == "YeS":
            break
        elif nextNumber == "no" or nextNumber == "No" or nextNumber == "nO" or nextNumber == "NO":
            whileLoop1 = 1
            print(sum(numList))
        else:
            print("Please only type Yes or No")
            slp(2.5)
            system('cls')
		data = []
		resp = None
		while not resp:
			try:
				user_agent = self.user_agents_cycle.next()
				resp = requests.get(url_, headers = {'user_agent': user_agent})
			except Exception, e:
				print str(e), '@@@'
				slp(10)
				pass
		if resp.status_code == 200 or len(self.get_static_resource(self.fixed_test_url)):
			data = pq_(resp.text)
			data = data('#results').children()
			return data
		else:
			slp(1)
			return self.get_resource(url_, counter+1)

	def get_static_resource(self, url):
		data = []
		resp = None
		try:
			while not resp:
				try:
					user_agent = self.user_agents_cycle.next()
					resp = requests.get(url, headers = {'user_agent': user_agent})
				except Exception, e:
					print str(e), '!!!'
					slp(5)
					pass
			if resp.status_code == 200:
choixn1=0
print("Bienvenue dans le convertisseur de monnaie le plus fun au monde !!")
print("Veux-tu convertir differentes monnaies ?")
print("Oui, ou Non")


while True:


    choixn1=input()
    choixn1=Minuscule(choixn1)
    if choixn1=='oui':
        break
    elif choixn1=='non':
        print("Dommage...")
        slp(1.5)
        exit()
    else:
        print(str(choixn1)+" n'est pas une entree valide...")


sys('cls')


monnaie1=''
monnaie2=''
monnaie1value=0.0
conversion=0.0


while True:
    bp(2500,500)
    bp(2200,500)
    bp(2200,500)
    bp(2000,500)

print('Bonjour et bienvenue dans le jeu du plus ou moins !!')
print("Le principe est simple, l'ordinateur choisi un nombre aleatoirement et tu dois le decouvrir !")

while True:
    choix_jouer=input('Veux-tu jouer , Oui/Non ')
    choix_jouer=Minuscule(choix_jouer)
    if choix_jouer=='oui':
        break
    elif choix_jouer=='non':
        print("Dommage... :'(")
        slp(1.5)
        exit()
    else:
        print('Desole mais '+Entree+' n\'est pas une reponse valide...')

while True:

    not_alone=Multi()

    while int(Diff)==0:
        sys('cls')
        print('Choisis ta difficulte : ')
        print('\n1)Facile')
        print('2)Moyen')
        print('3)Difficile')
        print('4)Personnalise')
            try:
                if n_files % increment == 0:
                    begin_index = begin_index + increment

                directory = root + "%d-%d" % (begin_index, begin_index + increment)
                if not os.path.exists(directory):
                    os.makedirs(directory)
                data = indeed_resumes_details(indeed_id).resource_collection()
                filename = "%s/%s.json" % (directory, indeed_id)
                f = open(filename, "wb")
                f.write(json.dumps(data))
                f.close()
                n_files += 1
            except Exception, e:
                print str(e)
                slp(300)
    con.close()
    return


if __name__ == "__main__":
    # save_profiles('../../backup/indeed-master-01.db')
    t1 = tm()
    for i in range(1000):
        obj = indeed_resumes_details("c3a2e69dd2e2ea83")
        data = obj.resource_collection()
        print data
        slp(0.7)
    t2 = tm()
    print t2 - t1