def cmd_start(self): cbt = functions.cbt(tid) if (ctype == 'private' or tid in const.admins) and cbt is True: mtext = message.text if len(mtext.split()) > 1: if mtext.split()[1]: ref = mtext.split()[1].replace('ref', '') tid_sql = sql('request', "SELECT tid FROM users WHERE tid='" + str(tid) + "'") if tid_sql is None: if str(ref) != str(tid): tid_ref = sql('request', "SELECT * FROM refs WHERE tid='" + str(tid) + "'") if tid_ref is None: sql('update', "INSERT INTO refs (tid, from_ref) VALUES ('" + str(tid) + "', '" + ref + "')") elif tid_ref is not None: bot.send_message(cid, lang.ref1) else: bot.send_message(cid, lang.ref2) else: bot.send_message(cid, lang.ref3) tid_sql = sql('request', "SELECT tid FROM users WHERE tid='" + str(tid) + "'") if tid_sql is None: keyboard = InlineKeyboardMarkup() keyboard.add(InlineKeyboardButton(text='English', callback_data='english'), InlineKeyboardButton(text='Русский', callback_data='russian')) bot.send_message(cid, 'Выберите язык / Choose language', reply_markup=keyboard) elif tid_sql is not None: Modules(self).start()
def decrypt(pw): pw = md5.md5(pw).hexdigest() fff = sql.sql('select name from files') print '' print 'Searching for locked files...' print '' for i in fff: print i[0] if not fff: print 'No Locked files found' else: if 1: print '' print 'Found %s files' % (len(fff)) print '' files = raw_input('Enter File name to unlock: ') mm2 = {} abc = sql.sql('select data from files where name="%s"' % (files)) c = open( 'sas/' + (sql.sql('select fname from files where name="%s"' % (files)))[0][0] + 'log.sas', 'r') exx = 'e=' + c.read() exec(exx) e2 = [str(i + int(pw[-5], 16)) for i in range(len(e))][::-1] c.close() for i in range(len(e)): mm2[e2[i]] = e[i] ddd = '''''' ab = abc[0][0] en = sql.sql('select enc from files where name="%s"' % (files)) if en[0][0] == 'y': try: ab = mycrypter.dec(ab, int(hashe.key(pw))) except Exception as i: print i elif en[0][0] == 'n': pass else: print en[0][0] for i in ab.split('.'): if i != '': ddd += mm2[i] hh = open(files, 'wb+') hh.write(ddd) print 'file %s unlocked successfully!' % (files) hh.close()
def __init__(self,url,baseWay='./videoData/',config='config',proxy=(False,'127.0.0.1',0)): if url[-1]=='/': self.__url=url else: self.__url=url+'/' self.host=self.__url.replace('http://','').replace('https://','').split('/')[0] self.header=[ "Host: "+self.host, "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0", "Accept: */*", "Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2", "Connection: keep-alive", "Referer: http://"+self.host+"/forum.php" ] if baseWay[-1]=='/': self.__baseWay=baseWay else: self.__baseWay=baseWay+'/' self.__fileName='介绍.txt' self.__proxy=proxy self.__proxyDict={ "http":"http://"+self.__proxy[1]+':'+str(self.__proxy[2])+'/', "https":"https://"+self.__proxy[1]+':'+str(self.__proxy[2])+'/', } self.__waitData=[] self.__weiNum=10 self.__sql=sql.sql(config=config)
def tosql(self): db = sql.sql() db.connect() nofound_station_array = db.addline(self.train_name,self.viasite,self.offical_train_no) self.temp_add_station_sql(self,nofound_station_array) #将没有添加的站点添加到数据库 db.addline(self.train_name,self.viasite,self.offical_train_no) db.close()
def __init__(self, id_plan, edad_min, edad_max, fecha_inicio): #Método principal de la clase self.__id_plan = id_plan self.__edad_min = edad_min self.__edad_max = edad_max self.__fecha_inicio = fecha_inicio self.__sql = sql()
def adm(message): if (str(message.chat.id) == "296823509"): bot.send_message(message.chat.id, "Добро пожаловать, лохебаный", parse_mode="Markdown", reply_markup=Adminmenu()) sqool = sql.sql() hlp = Helper.Helper() do25 = hlp.filesdo25() posle25 = hlp.filesposle25() im = Names while (True): randdo25 = random.randint(0, len(do25)) - 1 randposle25 = random.randint(0, len(posle25)) - 1 if (randdo25 == -1 or randposle25 == -1): continue break while (True): if (sqool.cityregret(message.chat.id) == 0): sqool.addcity(message.chat.id, message.text) sqool.zerotoone(message.chat.id) bot.send_message(message.chat.id, "Выберите возраст", parse_mode="Markdown", reply_markup=Menu()) print("1") break else: if (message.text == "Познакомиться после 25"): photo = open(posle25[randposle25], 'rb') try: bot.send_photo(message.chat.id, photo, randomname(), reply_markup=inlkeyboardposle25()) break except: print("Ошибка #1") continue elif (message.text == "Познакомиться до 25"): photo = open(do25[randdo25], 'rb') try: bot.send_photo(message.chat.id, photo, randomname(), reply_markup=inlkeyboarddo25()) break except: print("Ошибка #2") continue elif (str(message.chat.id) == "296823509" and message.text == "Статистика"): try: bot.send_message(message.chat.id, sqool.statistika()) break except: print("Ошибка #3") continue
def control(): func=raw_input('[cldog] ^_^ ') type(func) if func == ':proxy': proxy.netSet() if func == ':set': set.set() if func ==':help': help.help() if func == ':shell': shell.shell() if func == ':sql-set': sqlset.sqlSet() if func == ':sql': sql.sql() if func == ':exit': exit(0)
def saveStockList(insert, update): s = sql() insert_head_sql = constants.insert_head_sql s.operation(insert_head_sql, insert) update_head_sql = constants.update_head_sql s.operation(update_head_sql, update)
def getRangeInfo(front, rear): select_range_info_sql = constants.select_tclose_range_sql % (front, rear) s = sql() data = s.select(select_range_info_sql) ans = [] for item in data: ans.append(item[0]) return ans
def query(): if request.method == 'GET': return render_template('query.html') elif request.method == 'POST': position = request.form.get('position') type = request.form.get('type') date = request.form.get('date') keyword = request.form.get('keyword') result = sql(position, type, date, keyword) return render_template('query.html', result=result)
def getInfomation(code): select_info_sql = constants.select_tclose_turnover_sql % code s = sql() data = s.select(select_info_sql) ans = [] for item in data: ans.append([float(item[0]), float(item[1])]) return ans
def getTurnoverInfo(code): select_turnover_sql = constants.select_turnover_sql % code s = sql() data = s.select(select_turnover_sql) ans = [] for item in data: ans.append(float(item[0])) return ans
def run(): global db db = sql(config.db_host, config.db_user, config.db_passwd, config.db_db) while True: try: scan_new() scan_events() time.sleep(1) except Exception as e: log.log(e)
def main(self, wnd): conn = False curses.echo() self.view = sefview.Sefview(wnd) self.view.writeError("Skriv inn databasepassord") self.db = sql.sql(self.view) while conn == False: try: pw = self.view.readInput() self.db.connect(pw) conn = True self.view.writeError("") except Exception: self.view.writeError("Kunne ikke koble til database, prov igjen:") self.updatestats() self.kritemode = False while True: self.view.beerRankStat(self.stats) if self.kritemode == True: self.view.writeError("KRITEMODE!!!! (trykk k for vanlig modus)") # else: # self.view.writeError("") self.view.createWnds() self.view.drawLogo() # view.drawScanProduct() key = self.view.readInput() if self.db.is_product(key): self.buy(key) """elif key == 'k': #kritemode? self.kritemode = True """ if key == "k": self.kritemode = not self.kritemode if self.kritemode == False: self.view.writeError("") elif key == "addperson": self.addperson() elif key == "addproduct": self.addproduct() elif key == "remperson": # NOT NEEDED # TODO self.view.writeError("not implemented") elif key == "remproduct": # NOT NEEDED # TODO self.view.writeError("not implemented") elif key == "updateq": # prodnr og antall self.updateq() elif key == "help": self.help() elif key == "quit": sys.exit(0)
def lang(tid): lang_sql = sql('request', "SELECT lang FROM users WHERE tid='" + str(tid) + "'") if lang_sql is None: lang = ru if lang_sql is not None: lg = lang_sql if lg == 'russian': lang = ru elif lg == 'english': lang = en return lang
def judgeOrSaveStockInfo(currentTime, flag): # 获取文件夹里的csv root = constants.stockInfoPath root = root + currentTime + '/' filePath = os.listdir(root) ans = [] num = 0 for file in filePath: #若是缓存垃圾文件则继续 if '.csv' not in file: continue #获得股票代码 code = file.replace('.csv','') #打开股票列表 file = root + file f = open(file, 'rt', encoding='gbk') f.seek(0) record = csv.reader(f) items = [] idx = 0 for item in record: #跳过第一行 if idx == 0: idx = 1 continue #保存有错误数据的股票代码,方便重新获取 if len(item) != 15: ans.append(code) break if flag == 1: #上市首日计算指标为None,方便插入库改为0.0(后期若用该指标得考虑上市首日特殊情况) for index, value in enumerate(item): if 'None' in value: item[index] = '0.0' #替换掉一些特殊字符 item[0] = item[0].replace('-', '') item[1] = item[1].replace('\'', '') if 'e' in item[13]: item[13] = str(float(item[13])) if 'e' in item[14]: item[14] = str(float(item[14])) items.append(item) if flag == 1: s = sql() s.operation(constants.insert_limb_sql, items) num = num + 1 print(num, code+'入库成功') return ans
def getInfo(front, rear): front = (date.today() + timedelta(days=front)).strftime("%Y%m%d") rear = (date.today() + timedelta(days=rear)).strftime("%Y%m%d") select_turnover_sql = constants.select_turnover_sql % (front, rear) s = sql() data = s.select(select_turnover_sql) ans = [] for item in data: ans.append([item[0], float(item[1]), float(item[2])]) return ans
def start(message): sql1 = sql.sql() if (sql1.select(message.chat.id)): bot.send_message(message.chat.id, "Добро пожаловать", parse_mode="Markdown", reply_markup=Menu()) else: sql1.regisrt(message.chat.id) print("Зарегестрировали " + str(message.chat.id)) bot.send_message(message.chat.id, "Введите город", parse_mode="Markdown")
def usermap(): area = sql.sql('cs') nw = {} for x in area.get_nw(): nw[x[0].encode('utf8')] = x[1:] usermap = [] name = 'name' value = 'value' for x in area.get_usermap(): usermap.append({name:x[0],value:x[1]}) # maxnum = max([x for x in usermap]) # usermap = area.get_usermap() return render_template("render.html", nw = nw)
def operateCompanyInfo(companyList, cnt): c = companyInfo() idx = cnt for company in companyList: infoList = c.method(company) s = sql() s.operate(constants.insert_body_sql, infoList) #打印下爬取的上市公司基本信息 print(idx, infoList) idx = idx + 1
def __init__(self, no_lote, fabrica, tipo_vac, cant_recibida, cant_usada, cant_asignada, no_dosis, temperatura, efectividad, proteccion, fecha_vencimiento, imagen): self.__no_lote=no_lote self.__fabrica=fabrica self.__tipo_vac=tipo_vac self.__cant_recibida=cant_recibida self.__cant_usada=cant_usada self.__cant_asignada=cant_asignada self.__no_dosis=no_dosis self.__temperatura=temperatura self.__efectividad=efectividad self.__proteccion=proteccion self.__fecha_vencimiento=fecha_vencimiento self.__imagen=imagen self.__sql=sql()
def start(self): keyb = ReplyKeyboardMarkup(resize_keyboard=True, row_width=2) keyb.add(*[KeyboardButton(text=name) for name in lang.main]) curr = sql('request', "SELECT currency FROM users WHERE tid='" + str(tid) + "'") buy_rub = functions.truncate(functions.buy_price() * functions.usd_rate(curr)) sell_rub = functions.truncate(functions.sell_price() * functions.usd_rate(curr)) buy_price = functions.truncate(functions.buy_price(), 4) sell_price = functions.truncate(functions.sell_price(), 4) bot.send_message(cid, lang.start_cmd.format(buy_price, buy_rub, curr, sell_price, sell_rub, curr), reply_markup=keyb, parse_mode='markdown')
def __init__(self, url, config='config', proxy=(False, '127.0.0.1', 0)): ''' 该class是为了获取二级下的列表详情 如 亚洲无码、欧美无码下有哪些页面 ''' self.__webList = { '亚洲无码': 'forum-181-%s.html', '亚洲有码': 'forum-220-%s.html', '欧美无码': 'forum-182-%s.html', '国内原创': 'forum-69-%s.html', '三级电影': 'forum-73-%s.html', '蓝光原盘': 'forum-177-%s.html', '资源合集': 'forum-203-%s.html', '热门电影': 'forum-196-%s.html', '性爱自拍图片': 'forum-42-%s.html', '美图写真': 'forum-137-%s.html', '人体艺术图片': 'forum-56-%s.html', '街头抓拍': 'forum-57-%s.html', '欧美图片': 'forum-221-%s.html', 'AV美图': 'forum-239-%s.html', '动态图区': 'forum-200-%s.html', '漫画': 'forum-307-%s.html' } if url[-1] == '/': self.__url = url else: self.__url = url + '/' self.__proxy = proxy self.__proxyDict = { "http": "http://" + self.__proxy[1] + ':' + str(self.__proxy[2]) + '/', "https": "https://" + self.__proxy[1] + ':' + str(self.__proxy[2]) + '/', } self.host = self.__url.replace('http://', '').replace('https://', '').split('/')[0] self.__nowJod = list(self.__webList.keys())[0] self.__nowJodUrl = self.__url + self.__webList[self.__nowJod] self.__deep = -1 self.__session = requests.session() self.__sql = sql.sql(config=config)
def __init__(self, url, config='config', proxy=(False, '127.0.0.1', 0)): self.__sql = sql.sql(config=config) self.__weiNum = 10 self.__waitUrl = [] self.__badUrlList = ['http://thzd.cc/'] self.__session = requests.session() self.__proxy = proxy self.__proxyDict = { "http": "http://" + self.__proxy[1] + ':' + str(self.__proxy[2]) + '/', "https": "https://" + self.__proxy[1] + ':' + str(self.__proxy[2]) + '/', } if url[-1] == '/': self.__url = url else: self.__url = url + '/' self.host = self.__url.replace('http://', '').replace('https://', '').split('/')[0] self.__xpathStr = { '二级分类': ['//h1[@class="ts"]/a/text()'], '名称': ['//*[@id="thread_subject"]/text()'], '详情ID': ['//td[@class="t_f"]/@id'], '详情': ['//*[@id="%s"]/text()'], 'img': [ '//*[@id="%s"]//img/@file', '//div[@class="pattl"]//img/@zoomfile', '/html/body/div[7]/div[4]/div[2]/div[1]/table/tbody/tr[1]/td[2]/div[2]/div/div[1]/table/tbody/tr/td/img/@src', "//img[starts-with(@id, 'aimg_')]/@file" ], '下载名': [ '//div[@class="pattl"]//a[@target="_blank"]/text()', '//td[@id="%s"]//a[@target="_blank"]/text()' ], '下载链接': [ '//div[@class="pattl"]//a[@target="_blank"]/@href', '//td[@id="%s"]//a[@target="_blank"]/@href' ] } self.__reStr = {'': [""]} self.__badList = ['jpg', 'png', 'JPG', 'PNG', '下载附件']
def cbt(tid): # 0 - Альфа # 1 - ЗБТ # 2 - Релиз status = int(sql('request', "SELECT cbt FROM status")) if tid in const.admins: return True elif status == 0: return False elif status == 1: admins = bot.get_chat_administrators(-1001386519148) testers_list = [] for i in admins: testers_list.append(i.user.id) if tid in testers_list: return True else: return False elif status == 2: return True
def main(): # Create the tmp backup directories checkDir(config.tmpDir) # Start off our log logWrite("********** START OF LOG **********") logWrite("Backup process started.") # Set the SQL Backup path, and dump the backup logWrite("Creating database backup...") sqlStatus = sql(sqlTmpDir, backupName) logWrite(sqlStatus['log']) # Process the filesystem backups logWrite("Creating filesystem backup...") fsStatus = fs(sqlTmpDir, sqlStatus['enabled'], backupName, config.tmpDir) logWrite(fsStatus['log']) # Push file to backup destination logWrite("Pushing backup to configured provider(s)...") pushStatus = provider(backupType, fsStatus['file'], config.tmpDir) logWrite(pushStatus['log']) # If the backup push was successful, delete the tmp backup folder. if pushStatus['status'] == True: # Delete the DB Backup file. Since this is added to the archive, no need to keep it if the archive # copy fails. logWrite("Deleting temporary backup files.") shutil.rmtree(config.tmpDir) else: # remove the sql backup directory, since it's already in the archive, and add the failure to the log try: shutil.rmtree(sqlTmpDir) except: logWrite("No tmp sql dir to remove") logWrite("There was an issue pushing the local backup.\n Backup is located in " + config.tmpDir) logWrite(pushStatus['log']) logWrite("Backup process complete.") logWrite("********** END OF LOG **********\n\n")
#!/usr/bin/env python from pprint import pprint import datetime import sql import time import os # cd to this scripts directory os.chdir(os.path.dirname(__file__)) s = sql.sql(sql.sql.dict_factory) cursor = s.cursor() cities = cursor.execute("SELECT city_id,name,zip_code FROM cities").fetchall() weather = cursor.execute("SELECT * FROM weather LEFT JOIN cities ON cities.city_id = weather.city_id ORDER BY dt ").fetchall() data = [] for elm in weather: if elm['zip_code'] != '80501': continue data.append((elm['dt'],elm['temperature']-273.15)) # pprint(data) x,y = tuple(zip(*data)) import matplotlib.pyplot as plt plt.plot(x,y) plt.show()
#!/usr/local/bin/env python3 #-*- coding = utf-8 -*- from checker import check import irc import sql import user i = irc.irc() s = sql.sql() with s: i.irc_conn() i.login() for ch in s.show_channels(): i.add_channel(ch[1]) i.join_all() while (1): try: buffer = i.IRC.recv(1024).decode("iso-2022-jp") except UnicodeDecodeError as e: buffer = "ERROR: UnicodeDecodeError" msg = buffer.split() print(msg) #PING PONG if msg[0] == "PING": i.send_data("PONG %s" % msg[1]) if len(msg) >= 4 and msg[1] == "PRIVMSG": check(buffer, msg, i, s) """
def GET(self): __sql = _sql.sql(working_directory) sigs = settings.VALID_SIG.split(',') return __sql.status_all(sigs)
def GET(self): __sql = _sql.sql(working_directory) sigs = settings.VALID_SIG.split(',') return __sql.recurring_status('rcr', False)
def saveCompanyInfo(infoList): s = sql() s.operation(constants.insert_body_sql, infoList)
coin = 'BIP' currency = ['RUB', 'USD', 'EUR'] langs = ['english', 'russian'] admins = [111489667, 200711590] users = [ 723744060, 186365094, 958241771, 591253, 108794197, 373946570, 710303458, 270224738, 882811101, 340447474, 71731775 ] mobile = 200 min_mob = 15 group_cid = -1001386519148 main = ['Платежи', 'Кабинет', 'История'] numverify = 'http://apilayer.net/api/validate' mnemonic = base64.b64decode( 'dmFzdCBzdGVhayB0b21hdG8gYXBhcnQga25vdyBob2xkIGxpYmVydHkgbWFnaWMgYmVuZWZpdCBlbmhhbmNlIGp1aWNlIHNvY2Nlcg==' ).decode('utf-8') # QIWI qiwi_login = base64.b64decode('Kzc5OTUxMjMwMzk1').decode('utf-8') qiwi_token = base64.b64decode( 'YzY0ZDdlMGQwNmJiNjA2NDcyZGU5MzMwYzZhYzQ0NzQ=').decode('utf-8') # Mainnet node_url = sql('request', "SELECT url FROM nodes WHERE status='1'") explorer_api_url = 'https://explorer-api.minter.network/api/v1' # Testnet test_node_url = 'https://api.testnet.minter.stakeholder.space' test_explorer_api_url = 'https://explorer-api.testnet.minter.network/api/v1'
def __init__(self, user_id = None): self.sql = sql() if(user_id): self.user_id = user_id self.shard_id = user_id % 2000
#!/usr/local/bin/env python3 #-*- coding = utf-8 -*- from checker import check import irc import sql import user i = irc.irc() s = sql.sql() with s: i.irc_conn() i.login() for ch in s.show_channels(): i.add_channel(ch[1]) i.join_all() while(1): try: buffer = i.IRC.recv(1024).decode("iso-2022-jp") except UnicodeDecodeError as e: buffer = "ERROR: UnicodeDecodeError" msg = buffer.split() print(msg) #PING PONG if msg[0] == "PING": i.send_data("PONG %s" % msg[1]) if len(msg) >= 4 and msg[1] == "PRIVMSG": check(buffer, msg, i, s) """
def signin(data): user = sql.sql('cs') password = hashlib.sha224(password).hexdigest()