示例#1
0
def add_computer():
    """
    Reads in Text file created by powershell() assigns it to a variable then
    passes the Info to Computer, LastLogon Class which creates an object.
    Lastly the function passes the returned object to db.insert data
    """

    file1 = 'f:\Windows_10_Refresh\Powershell\SysConfig.txt'
    with open (file1, 'r') as f1:

        text = f1.read().splitlines()

        if text:
            name = text[0]
            username = text[1]
            windows = text[2]
            cpu = text[3]
            currentamount = text[4]
            totalslots = text[5]
            lastlogon = text[6]
            ipaddress = text[7]

            computer = Computer(name=name, username=username,
                                windows=windows, cpu=cpu,
                                currentamount=currentamount,
                                totalslots=totalslots,
                                lastlogon=lastlogon, ipaddress=ipaddress)
            db.update_data(computer)

        else:
            print("")
示例#2
0
def get_maximum_price(message):
    while int(db.get_user(message.from_user.username)['max_price']) == -1:
        try:
            max_price = int(
                message.text) if int(message.text) >= 0 else bot.send_message(
                    message.chat.id, 'Please, enter correct price')

            db.update_data(message.from_user.username, 'max_price', max_price)
            user = db.get_user(message.from_user.username)
            search_type = user['search_type']
            beds = user['beds']
            baths = user['baths']
            min_price = user['min_price']
            max_price = user['max_price']

            markup = types.InlineKeyboardMarkup(row_width=2)
            markup.add(
                types.InlineKeyboardButton('Yes', callback_data='correct'),
                types.InlineKeyboardButton('No', callback_data='incorrect'))

            bot.send_message(
                message.chat.id,
                f'You want to {search_type} Property\nCity: San Fransico\nBeds: {beds}\nBaths: {baths}\nMin Price: {min_price}\nMax Price: {max_price}\n',
                reply_markup=markup)

        except Exception as e:
            print(e)
示例#3
0
def get_data(movie_id):
    url = "https://movie.douban.com/subject/{}".format(movie_id)
    r = requests.get(url, headers=HEADERS)
    if r.status_code != 200:
        raise Exception(r.status_code)
    content = r.content
    s = content.find("<span class=\"year\">")
    s = content.find("(", s + 1)
    e = content.find("</span>", s + 1)
    year = int(content[s + 1:e - 1])
    s = content.find("<script type=\"application/ld+json\">")
    s = content.find("{", s + 1)
    e = content.find("</script>", s + 1)
    json_data = json.loads(content[s:e - 1], strict=False)
    name = json_data.get(u'name')
    score = json_data.get(u'aggregateRating').get(u'ratingValue')
    if score:
        score = float(score)
    else:
        score = "NULL"
    votes = json_data.get(u'aggregateRating').get(u'ratingCount')
    if votes:
        votes = int(votes)
    else:
        votes = "NULL"
    if db.check_exists(movie_id):
        db.update_data(movie_id, name, year, score, votes)
    else:
        db.insert_data(movie_id, name, year, score, votes)
    logging.info("finish %s %s %s %s %s", movie_id, name, year, score, votes)
    global backup_list
    if len(backup_list) < 100:
        find_next(content)
示例#4
0
def user_entering_description(message):
    if len(message.text) < 10 or len(message.text) > 255:
        bot.send_message(message.chat.id, "Слишком короткое/длинное описание!")
        return
    else:
        db.update_data(message.from_user.id, 'description', message.text)
        bot.send_message(message.chat.id, "Хорошо, введите цену (BYN):")
        db.set_state(message.chat.id, config.States.S_SEND_PRICE.value)
示例#5
0
def user_entering_title(message):
    if len(message.text) < 3 or len(message.text) > 30:
        bot.send_message(message.chat.id, "Слишком короткое/длинное название!")
        return
    else:
        db.update_data(message.from_user.id, 'title', message.text)
        bot.send_message(message.chat.id, "Понял, теперь описание:")
        db.set_state(message.chat.id, config.States.S_SEND_DESCRIPTION.value)
示例#6
0
def user_entering_city(message):
    if len(message.text) < 2 or len(message.text) > 30:
        bot.send_message(message.chat.id, "Введите настоящий город!")
        return
    else:
        db.update_data(message.from_user.id, 'city', message.text)
        bot.send_message(message.chat.id, "Хорошо, ваш заголовок:")
        db.set_state(message.chat.id, config.States.S_SEND_TITLE.value)
示例#7
0
def user_entering_price(message):
    if not message.text.isdigit():
        bot.send_message(message.chat.id, "Только цифры:)")
        return
    if int(message.text) < 1 or int(message.text) > 10000:
        bot.send_message(message.chat.id, "Введите нормальную цену:)")
        return
    else:
        db.update_data(message.from_user.id, 'price', message.text)
        bot.send_message(message.chat.id, "Пришлите мне одно фото товара")
        db.set_state(message.chat.id, config.States.S_SEND_PHOTO.value)
示例#8
0
def get_minimum_price(message):
    while int(db.get_user(message.from_user.username)['min_price']) == -1:
        try:
            min_price = int(
                message.text) if int(message.text) >= 0 else bot.send_message(
                    message.chat.id, 'Please, enter correct price')

            db.update_data(message.from_user.username, 'min_price', min_price)

            bot.send_message(message.chat.id, "Write the maximum price.")
            bot.register_next_step_handler(message, get_maximum_price)
        except Exception as e:
            pass
示例#9
0
def user_sending_photo(message):
    contacts = "@{}".format(message.from_user.username)
    db.update_data(message.from_user.id, 'contacts', contacts)
    db.update_data(message.from_user.id, 'photo', message.photo[-1].file_id)
    result = db.fetch(message.from_user.id)
    announc = Announcement(result)
    bot.send_photo(
        message.chat.id,
        photo=announc.photo,
        caption="Поздравляю! Можете отправить объявление на модерацию.\n\n{}".
        format(announc.showInfo()),
        reply_markup=keyboard.endKeyboard(),
        parse_mode="Markdown")
    db.set_state(message.chat.id, config.States.S_START.value)
示例#10
0
    def popup_bearbeiten(self):
        """
        Ruft das Popup Eintrag Bearbeiten und ruft ein columntree Update.
        """        
        selected = self.columntree.selection()
        if len(selected) < 1:
            messagebox.showinfo(title="Fehler", 
                            message="Kein Eintrag zum Bearbeiten ausgewählt!")
        elif len(selected) > 1:
            selected = self.columntree.selection()
            t_ids_bezahlt = []
            for item in selected:
                t_ids_bezahlt.append((self.columntree.set(item, column="id"),
                                self.columntree.set(item, column="bezahlt")))
    
            popup = Toplevel(self)
            d = popup_bearbeiten_bezahlt.EintraegeBearbeiten(t_ids_bezahlt, 
                                                             popup)
            popup.update_idletasks()
            popup.update()
            popup.focus_set()
            popup.grab_set()
            popup.wait_window(popup)
            if d.result:
                db.update_data_bezahlt(d.result)

                self.update_tabelle()

        else:
            t_id = self.columntree.set(selected[0], column="id")
            datum = self.columntree.set(selected[0], column="datum")
            projekt = self.columntree.set(selected[0], column="projekt")
            startzeit = self.columntree.set(selected[0], column="startzeit")
            endzeit = self.columntree.set(selected[0], column="endzeit")
            protokoll = self.columntree.set(selected[0], column="protokoll")
            bezahlt = self.columntree.set(selected[0], column="bezahlt")

            popup = Toplevel(self)
            d = popup_bearbeiten.EintragBearbeiten(t_id, datum, projekt, 
                                                   startzeit, endzeit, 
                                                   protokoll, bezahlt, popup)
            popup.update_idletasks()
            popup.update()
            popup.focus_set()
            popup.grab_set()
            popup.wait_window(popup)
            if d.result:
                db.update_data(d.result)
            
                self.update_tabelle()
示例#11
0
 def editar(self):
     print("---------------")
     print("Editar contacto")
     print("---------------")
     nom_buscado = input("Introduzca el nombre del contacto: ")
     get_data(nom_buscado)
     print(
         'A continuacion solicitaremos que ingrese los datos para actualizarlos'
     )
     nombre = input("Introduzca el nuevo nombre: ")
     apellido = input("Introduzca el nuevo apellido: ")
     telefono = input("Introduzca el nuevo teléfono: ")
     email = input("Introduzca el nuevo email: ")
     update_data(nom_buscado, nombre, apellido, telefono, email)
     '''condition = False
示例#12
0
文件: app.py 项目: MDLGH48/hcrm
def update_user_data():
    user_id = jwt.decode(request.headers.get('token')[1:-1],
                         app.config['SECRET_KEY'],
                         algorithms='HS256')["user"]
    request_body = request.get_json()
    data = request_body["data"]
    return jsonify(update_data(user_id, data))
示例#13
0
文件: bot.py 项目: Sigbln/tgbot
def mess(message):
    resp = db.update_data()
    subs = db.get_subs()
    for user in subs:
        bot.send_message(user[1],
                         messages.mess_gen(resp),
                         parse_mode="Markdown")
示例#14
0
def get_baths_num(message):
    while int(db.get_user(message.from_user.username)['baths']) == 0:
        try:
            if int(message.text) <= 0:
                bot.send_message(message.chat.id,
                                 'Number of baths cannot be less than zero')
            elif int(message.text) > 6:
                bot.send_message(
                    message.chat.id,
                    'It should be very big house, please try again')
            else:
                baths = int(message.text)

                db.update_data(message.from_user.username, 'baths', baths)

                bot.send_message(message.chat.id, "Write the minimum price.")
                bot.register_next_step_handler(message, get_minimum_price)

        except Exception as e:
            bot.send_message(message.chat.id, 'Number of baths, please')
示例#15
0
def get_beds_num(message):
    while int(db.get_user(message.from_user.username)['beds']) == 0:
        try:
            if int(message.text) <= 0:
                bot.send_message(message.chat.id,
                                 'Number of beds cannot be less than zero')
            elif int(message.text) > 6:
                bot.send_message(
                    message.chat.id,
                    'It should be very big house, please try again')
            else:
                beds = int(message.text)

                db.update_data(message.from_user.username, 'beds', beds)

                bot.send_message(message.chat.id,
                                 'Write how many bathrooms do you want.')
                bot.register_next_step_handler(message, get_baths_num)
        except Exception as e:
            print(e)
            bot.send_message(message.chat.id, 'Number of beds, please')
示例#16
0
for i in data:
	print(i)
print('\n........................................................\n\n')
for i in data:
	check_protocolo(driver,wait,i)
	time.sleep(5)
	try:
		element = wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="situacaoViabilidade"]')))
	finally:
		status = driver.find_element_by_xpath('//*[@id="situacaoViabilidade"]')
		status= str(status.get_attribute('innerHTML'))
		status = status[1:]
	if status == "Deferida":
		print('... Protocolo Acima está Deferida!!!')
		TESTE_DOWNLOAD(driver,wait)
		update_data(i,status)
	elif status == "Indeferida":
		print('... Protocolo Acima está Indeferida!!!')
		TESTE_DOWNLOAD(driver,wait)
		update_data(i,status)
	elif status == "Cancelada Pelo Usuário":
		print('... Protocolo Acima Foi cancelada pelo Usuário!!!')
		update_data(i,status)
	elif status == "Protocolada'":
		print('... Protocolo Acima continua Protocolada!!!')
	print("-------------------------------------------------------\n\n")
driver.close()
print("\n...Encerrada a Verificação!!!\n-------------------------------------------------------\n\n")


示例#17
0
文件: main.py 项目: PiPiNaN/goodstudy
def updatehanzi(data):
    d = (data["hanzi"], data["type"], data["learned"], data["passed"],
         data["id"])
    r = db.update_data(db.sql_connection(), d)
    return r
示例#18
0
def user_entering_category(message):
    db.update_data(message.from_user.id, 'category', message.text)
    bot.send_message(message.chat.id,
                     "Супер. Напишите ваш город:",
                     reply_markup=keyboard.hideKeyboard())
    db.set_state(message.chat.id, config.States.S_ENTER_CITY.value)