def postinIntoUsers(content):
    # inserting into users:
    insertingIntoUser = ("INSERT into users"
                         "(userID, username,password,Usertype)"
                         "VALUES(%s,%s,%s,%s, %s)")
    userRow = (content[0], content[1], 'user', content[3])
    Mysql.post(insertingIntoUser, userRow)
Beispiel #2
0
def mysql_backup():
    MYSQL = Mysql.MYSQL(USER, PASSWORD, HOST, PORT, DB)
    cmds = "select ip,port from mysqldb where master='是';"
    results = MYSQL.Run(cmds)
    key = 'mysql_backup'
    Redis.delete('finish_backup')
    if results:
        try:
            for host in BACKUP_SERVERS:
                Redis.delete('%s_%s' % (key, host))
            i = len(BACKUP_SERVERS)
            for info in results:
                info = [str(m) for m in info]
                # 设置binlog过期时间
                MHOST, MPORT = info
                MDB = 'mysql'
                MYSQL_SET = Mysql.MYSQL(USER, PASSWORD, MHOST, MPORT, MDB)
                cmds = 'set global expire_logs_days=15;'
                MYSQL_SET.Run(cmds)
                if info[0] not in NOT_BACKUP_MYSQL:
                    i = i - 1
                    Redis.lpush('%s_%s' % (key, BACKUP_SERVERS[i]), info)
                    if i == 0:
                        i = len(BACKUP_SERVERS)
            MYSQL_SET.Close()
        except Exception as e:
            loging.write(e)
    MYSQL.Close()
Beispiel #3
0
Datei: Tina.py Projekt: AiAe/Tina
async def Tina():
    await bot.wait_until_ready()
    while not bot.is_closed:
        async with websockets.connect('wss://getdownon.it/storas-relay') as websocket:
            while True:
                try:
                  get = await websocket.recv()
                except:
                  await bot.send_message(discord.Object(id='348621766702268416'), "Websockets died... bot is turning off should be back shortly...")
                  await bot.logout()
                  await bot.close()
                statsd.increment('Tina.new_score')
                api = json.loads(get)
                Connection, Cursor = Mysql.connect()
                meme = Mysql.execute(Connection, Cursor, "SELECT * FROM tracking WHERE user_id = %s", [api["user_id"]])
                #then you basically loop the results, check if
                #modes & 2**score["mode"]
                #score["new_score"]["performance"] >= minpp
                #score["personal_top"] <= topplays or topplays == 0
                embed = None
                for x in meme:
                    if x["modes"] & 2**api["mode"] \
                       and api["new_score"]["performance"] >= x["minpp"] \
                       and (api["personal_top"] <= x["topplays"] or x["topplays"] == 0):
                        if not embed:
                            embed = make_message(api)
                        await bot.send_message(discord.Object(id=x["channel_id"]), embed=embed)
Beispiel #4
0
def commentCount():
    cursor = Mongo.sortAndCount()
    commentCount = [doc for doc in cursor]
    Mongo.close()
    print(type(commentCount[0]))
    Mysql.addCarCommentCount(commentCount)
    Mysql.close()
Beispiel #5
0
def task_tables_info():
    MYSQL_IDC = Mysql.MYSQL(USER, PASSWORD, HOST, PORT, DB)
    Table = 'tableinfo'
    cmds = ("TRUNCATE TABLE %s;" % Table, "select ip,port,db from mysqldb;")
    results = map(MYSQL_IDC.Run, cmds)
    for host, port, dbs in results[1]:
        try:
            if '172.16.9.' not in host:
                MYSQL = Mysql.MYSQL(USER, PASSWORD, host, port, 'mysql')
                cmd = "show variables like 'version';"
                version = MYSQL.Run(cmd)
                version = version[0][1] or 'None'
                for db in dbs.split('|'):
                    cmd = "show table status from %s;" % db
                    results = MYSQL.Run(cmd)
                    if results:
                        for table_info in results:
                            try:
                                Table_Name = table_info[0]
                                Engine = table_info[1] or 'None'
                                Rows = table_info[4] or 0
                                Charset = table_info[14] or 'None'
                                cmd = (
                                    "insert into %s (ip,port,database_name,table_name,Engine_name,Rows,Charset,version)  VALUES ('%s',%i,'%s','%s','%s',%i,'%s','%s');"
                                    % (Table, host, int(port), db, Table_Name,
                                       Engine, Rows, Charset, version))
                                MYSQL_IDC.Run(cmd)
                            except Exception as e:
                                logging.error(e)
                                continue
                MYSQL.Close()
        except Exception as e:
            logging.error(e)
            continue
    MYSQL_IDC.Close()
Beispiel #6
0
def get_download_link(arg):
    try:
        html = get_soup(arg + "/download?from=details")
        Mysql.update_apk_link(arg,
                              html.find("a", id="download_link").attrs["href"])
    except Exception, e:
        print e
Beispiel #7
0
def get_detail_apk(arg):
    try:
        html = get_soup(arg)
        tag = html.find("span", itemprop="fileSize")
        if tag is None:
            tag = html.find("span", class_="fsize")
        str_size = tag.text.split(" ")[0]
        if str_size[0:1] == "(":
            str_size = str_size[1:]
            print str_size
        size = string.atof(str_size)

        if tag.text.split(" ")[1] == "KB":
            size /= 1024
        if tag.text.split(" ")[1] == "GB":
            size *= 1024

        is_google = 0
        button = html.find_all("a", class_="ga")[1]
        link = button.attrs['href'].split("?")[0]
        if link == "https://play.google.com/store/apps/details":
            is_google = 1

        Mysql.update_apk_size(arg, size, is_google)
    except Exception, e:
        print e
def postintoTweets(content):
    insertingIntoTweets = (
        "INSERT into tweets"
        "(createdAt, tweetsID,text,category,twitterAccount, combinID)"
        "VALUES(%s,%s,%s,%s,%s,%s)")
    tweetRow = (content[0], content[1], content[2], content[3], content[4],
                content[5])
    Mysql.post(insertingIntoTweets, tweetRow)
Beispiel #9
0
	def tara(self, mozillaMaxHistoryId):
		self.newMaxId=int(MozillaDatabaseController.mozillaMaxIdGetir())
		if(mozillaMaxHistoryId<self.newMaxId):
			while(mozillaMaxHistoryId<self.newMaxId):
				kayıt=MozillaDatabaseController.mozillaGetirById(mozillaMaxHistoryId + 1)
				Mysql.kayıtEkle(kayıt[0],1,kayıt[1])
				mozillaMaxHistoryId= mozillaMaxHistoryId + 1
		return mozillaMaxHistoryId
def postingIntotweets_has_users(content, account, userID, newCloneID,
                                CloneTime, combineID):
    insetIntoTweetsHasUsers = (
        "INSERT into tweets_has_users"
        "(userID, cloneID, cloneTime, tweets_tweetsID, tweets_twitterAccount,tweets_combinID)"
        "VALUES(%s,%s,%s,%s,%s,%s)")
    sRow = (userID, newCloneID, CloneTime, content[1], account, combineID)
    Mysql.post(insetIntoTweetsHasUsers, sRow)
	def tara(self, mozillaMaxHistoryId):
		self.newMaxId=int(MozillaDatabaseController.mozillaMaxIdGetir())
		if(mozillaMaxHistoryId<self.newMaxId):
			while(mozillaMaxHistoryId<self.newMaxId):
				kayıt=MozillaDatabaseController.mozillaGetirById(mozillaMaxHistoryId + 1)
				Mysql.kayıtEkle(kayıt[0],1,kayıt[1])
				mozillaMaxHistoryId= mozillaMaxHistoryId + 1
		return mozillaMaxHistoryId
Beispiel #12
0
def retriveUsersByName(name):
    name = "'" + name + "'"
    if name == "'*'":
        usersQuery = ("select * from users")
        return Mysql.fetch(usersQuery)
    else:
        usersQuery = ("select * from users where firstName = " + name)
        return Mysql.fetch(usersQuery)
Beispiel #13
0
def updatePassword(password, userID):
    password = hashingPassword(password)
    row = (password, userID)
    updatingUsersAccount = ("UPDATE users set password = %s where userID = %s")
    Mysql.post(updatingUsersAccount, row)


#updatePassword('123m', 2)
Beispiel #14
0
def check_ip_all(ip):
    l_ip = Mysql.queryIP()
    if ip in l_ip:
        print("A")
        mal = Mysql.query_mal(ip)
    else:
        print("B")
        mal = Checkipvirustotal.check_ip(ip)
        time.sleep(25)
    return mal
	def Eliminar(self):
			rows = self.table.selectionModel().selectedRows()
			index = []
			for i in rows:
				index.append(i.row())
			index.sort(reverse=True)
			for i in index:
				url = self.table.item(i, 0).text()
				zaman = self.table.item(i, 1).text()
				self.table.removeRow(i)
				Mysql.historySil(url,zaman)
Beispiel #16
0
 def Eliminar(self):
     rows = self.table.selectionModel().selectedRows()
     index = []
     for i in rows:
         index.append(i.row())
     index.sort(reverse=True)
     for i in index:
         url = self.table.item(i, 0).text()
         zaman = self.table.item(i, 1).text()
         self.table.removeRow(i)
         Mysql.historySil(url, zaman)
Beispiel #17
0
def get_detail_page(arg):
    for i in range(10):
        if Mysql.search_apks(arg, i + 1) < 10:
            try:
                tags = get_soup(arg + "?page=" + str(i + 1)).find_all(
                    "div", class_="category-template-title")
                for tag in tags:
                    for link in tag.find_all("a"):
                        Mysql.insert_apks(arg, i + 1, link.attrs['href'])
            except Exception, e:
                print e
	def tara(self, googleMaxHistoryId=None):

			googleMaxHistoryId=int(googleMaxHistoryId)
			self.newMaxId=int(GoogleDatabaseController.googleMaxIdGetir())
			print(self.newMaxId)
			if(googleMaxHistoryId<self.newMaxId):
				while(googleMaxHistoryId<self.newMaxId):
					kayıt=GoogleDatabaseController.googleGetirById(googleMaxHistoryId + 1)
					Mysql.kayıtEkle(kayıt[0],2,kayıt[1])
					googleMaxHistoryId= googleMaxHistoryId + 1
			return googleMaxHistoryId
Beispiel #19
0
    def tara(self, googleMaxHistoryId=None):

        googleMaxHistoryId = int(googleMaxHistoryId)
        self.newMaxId = int(GoogleDatabaseController.googleMaxIdGetir())
        print(self.newMaxId)
        if (googleMaxHistoryId < self.newMaxId):
            while (googleMaxHistoryId < self.newMaxId):
                kayıt = GoogleDatabaseController.googleGetirById(
                    googleMaxHistoryId + 1)
                Mysql.kayıtEkle(kayıt[0], 2, kayıt[1])
                googleMaxHistoryId = googleMaxHistoryId + 1
        return googleMaxHistoryId
Beispiel #20
0
def checkingUsername(userName):
    queryForTheUsername = "******" + userName + "';"
    existence = Mysql.fetch(queryForTheUsername)
    if len(existence) == 0:
        return True
    else:
        return False
Beispiel #21
0
def setOutputeDB(totalDic):
    global categoryUP

    # DB登録
    d = datetime.datetime.today()
    print('d:', d, 'db update start')
    mysql = Mysql.Mysql()
    totalInstCount = 0
    totalUpdtCount = 0
    totalProcCount = 0
    for itemLine in totalDic["item"]:
        instCount = 0
        instCount = mysql.updateProductInfo(itemLine, categoryUP)
        totalProcCount += 1

        if ((totalProcCount % 100) == 0):
            time.sleep(10)

        time.sleep(0.01)
        if instCount == 1:
            totalInstCount += 1
        else:
            totalUpdtCount += 1

    print("db update finish! total:" + str(totalInstCount + totalUpdtCount) +
          " new:" + str(totalInstCount) + " update:" + str(totalUpdtCount))

    del mysql
    gc.collect()

    return
Beispiel #22
0
def get_twemproxy_redis():
    MYSQL = Mysql.MYSQL(USER, PASSWORD, HOST, PORT, DB)
    redis_info = {}
    for twemproxy_ip in TWEMPROXY_HOSTS:
        try:
            sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
            sock.connect((twemproxy_ip,22222))
            INFOS = json.loads(sock.recv(86400))
            for key in INFOS:
                if 'redis_' in key:
                    IP_list = []
                    for ip_key in INFOS[key]:
                        if '172.16.' in ip_key:
                            IP_list.append(ip_key.split(':')[0])
                    redis_info[key] = IP_list
        except Exception as e:
            loging.write(e)
            continue
    cmd = "TRUNCATE TABLE twemproxyInfo;"
    MYSQL.Run(cmd)
    for key in redis_info:
        for ip in redis_info[key]:
            try:
                Redis = redis.StrictRedis(host=ip,port=6379,db=0,socket_timeout=1)
                Keys = Redis.info()['db0']['keys']
                cmd = "insert into twemproxyInfo (serviceGroup,clientIP,clientKeyItems) VALUES('%s','%s','%s');"%(key,ip,Keys)
                MYSQL.Run(cmd)
            except:
                continue

    MYSQL.Close()
Beispiel #23
0
def chckingForCombinID():
    query = ("select max(combinID) from tweets ;")
    bigestCombinID = Mysql.fetch(query)
    if bigestCombinID[0][0] is None:
        return 1
    else:
        return bigestCombinID[0][0] + 1
Beispiel #24
0
def detection_rtsp():
    """rtsp Network connectivity detection"""
    try:
        mysqlobj = Mysql.Mysql()
        mysqlobj = mysqlobj.db_connect()
        command = "SELECT stream_url FROM camera"
        rtspobjs = mysqlobj.db_query(command)

        for rtspobj in rtspobjs:

            rtsp = 'ping ' + rtspobj + ' -c 5'
            print rtsp
            # rtsp = 'ping www.baidu.com -c 5'
            try:
                exit_code = os.system(rtsp)
            except Exception, e:
                print e
            if exit_code == 0:
                status = 'successful' + rtsp[3:-4]
                print status
                return status
            else:
                status = 'failing:' + str(exit_code) + rtsp[3:-4]
                print status
                return status

    except Exception, e:
        print(e)
def tweetSearchForAnotherAccount(text, account, userID):
    account = "'" + account + "'"
    # searchForText = ("select createdAt, text, category from tweets where text like '% "+text+" %' and twitterAccount = "+ account +"and tweetsID in (select tweets_tweetsID from tweets_has_users where cloneID = "+ cloneID +");")
    searchForText = "select createdAt, text, category from tweets where combinID in (select tweets_combinID from tweets_has_users where userID = " + str(
        userID
    ) + " and tweets_twitterAccount =" + account + ") and text like '% " + text + " %' ;"
    return Mysql.fetch(searchForText)
def termFrequency(account, userID):
    try:
        if account is None:
            return None
        else:
            vectorizer = TfidfVectorizer(sublinear_tf=True,
                                         max_df=0.5,
                                         min_df=3,
                                         stop_words='english',
                                         use_idf=True,
                                         token_pattern=u"\w{4,}",
                                         lowercase=True)
            account = "'" + account + "'"
            textForAccountandUser = "******" + str(
                userID) + " and tweets_twitterAccount =" + account + ")"
            texts = Mysql.fetch(textForAccountandUser)
            if len(texts) != 0:
                container = []
                for text in texts:
                    container.append(text[0])
                X = vectorizer.fit_transform(container)
                tempVoc = []
                counter = 0
                for x in sorted(vectorizer.vocabulary_.items(), reverse=True):
                    if counter == 10:
                        break
                    tempVoc.append(x)
                    counter = counter + 1
                return tempVoc
            else:
                print("Thre is no data")
    except:
        print('There is an error')
        return None
Beispiel #27
0
def chckingForCloneID():
    query = ("select max(cloneID) from tweets_has_users ;")
    bigestCloneID = Mysql.fetch(query)
    if bigestCloneID[0][0] is None:
        return 1
    else:
        return bigestCloneID[0][0] + 1
Beispiel #28
0
class MyForm_deploy_jboss(Form):
    haproxy = BooleanField(label='外部HAPROXY')
    haproxy_intranet = BooleanField(label='内部HAPROXY')
    input_domain = StringField(validators=[DataRequired(), Length(4, 64)])
    input_produce = StringField()
    val_produce, val_test = Mysql.db_produce('java')
    select_produce = SelectMultipleField(choices=[
        ('{0}:{1}'.format(va[1], va[0]), '{0}:{1}'.format(va[1], va[0]))
        for va in val_produce
    ],
                                         default=None)
    select_test = SelectMultipleField(choices=[('{0}:{1}'.format(va[1], va[0]),
                                                '{0}:{1}'.format(va[1], va[0]))
                                               for va in val_test],
                                      default=None)
    select_level = SelectField(
        choices=[('7', '7'), ('6', '6'), ('5',
                                          '5'), ('4',
                                                 '4'), ('3',
                                                        '3'), ('2',
                                                               '2'), ('1',
                                                                      '1')])
    input_test = StringField()
    submit_produce = SubmitField('提交', id='btn1')
    submit_test = SubmitField('提交', id='btn2')
Beispiel #29
0
def WAF3():
    DB = 'op'
    tt = time.strftime('%Y%m%d', time.localtime())
    tm = datetime.datetime.now() - datetime.timedelta(minutes=2)
    tm = tm.strftime('%Y%m%d%H%M')
    dm = datetime.datetime.now() + datetime.timedelta(days=1)
    expire_time = dm.strftime('%Y-%m-%d %H:%M:%S')
    black_ip_day = 'black_ip_%s' % tt
    black_ip_minute = 'black_ip_%s' % tm
    try:
        MYSQL = Mysql.MYSQL(USER, PASSWORD, HOST, PORT, DB)
        IP_LIST = RC.lrange(black_ip_minute, 0, -1)
        IP_LIST_DAY = RC.lrange(black_ip_day, 0, -1)
        if IP_LIST and IP_LIST_DAY:
            for ip in set(IP_LIST):
                if ip in set(IP_LIST_DAY):
                    try:
                        #全天拦截
                        MYSQL.Run(
                            "update haproxy_blacklist set expire = '%s' where ip = '%s';"
                            % (expire_time, ip))
                    except Exception as e:
                        logging.error(e)
                        continue
            MYSQL.Close()
    except Exception as e:
        logging.error(e)
Beispiel #30
0
def WAF2():
    DB = 'op'
    tt = time.strftime('%Y%m%d', time.localtime())
    th = time.strftime('%Y%m%d%H', time.localtime())
    tm = datetime.datetime.now() - datetime.timedelta(minutes=2)
    tm = tm.strftime('%Y%m%d%H%M')
    dm = datetime.datetime.now() + datetime.timedelta(hours=1)
    expire_time = dm.strftime('%Y-%m-%d %H:%M:%S')
    black_ip_minute = 'black_ip_%s' % tm
    black_ip_hour = 'black_ip_%s' % th
    black_ip_day = 'black_ip_%s' % tt
    try:
        MYSQL = Mysql.MYSQL(USER, PASSWORD, HOST, PORT, DB)
        IP_LIST = RC.lrange(black_ip_minute, 0, -1)
        IP_LIST_HOUR = RC.lrange(black_ip_hour, 0, -1)
        if IP_LIST and IP_LIST_HOUR:
            for ip in set(IP_LIST):
                if ip in set(IP_LIST_HOUR):
                    try:
                        #小时拦截
                        RC.lpush(black_ip_day, ip)
                        MYSQL.Run(
                            "update haproxy_blacklist set expire = '%s' where ip = '%s';"
                            % (expire_time, ip))
                    except Exception as e:
                        logging.error(e)
                        continue
            RC.expire(black_ip_day, 86400)
            MYSQL.Close()
    except Exception as e:
        logging.error(e)
Beispiel #31
0
def haproxy_blacklist():
    DB = 'op'
    MYSQL = Mysql.MYSQL(USER, PASSWORD, HOST, PORT, DB)
    file_path = '/tmp/blacklist'

    def write_ip():
        cmd = "SELECT ip FROM haproxy_blacklist;"
        hosts = [str(host[0]) for host in MYSQL.Run(cmd)]
        with open(file_path, 'w') as f:
            for host in hosts:
                f.write('%s\n' % host)
        for ip in HA_SERVERS:
            ssh = SSH.ssh('work', ip)
            ssh.Scp(file_path, file_path)

    tm = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
    cmd = "SELECT ip FROM haproxy_blacklist where expire <= '%s' and expire !='0000-00-00 00:00:00';" % tm
    if MYSQL.Run(cmd):
        cmd = "delete from haproxy_blacklist where expire <= '%s' and expire !='0000-00-00 00:00:00';" % tm
        MYSQL.Run(cmd)
        write_ip()
    cmd = "SELECT ip FROM haproxy_blacklist where stats = '1';"
    if MYSQL.Run(cmd):
        cmd = "update haproxy_blacklist set stats = '0';"
        MYSQL.Run(cmd)
        write_ip()
    cmd = "SELECT ip FROM haproxy_blacklist where stats = '2';"
    if MYSQL.Run(cmd):
        cmd = "delete from haproxy_blacklist where stats = '2';"
        MYSQL.Run(cmd)
        write_ip()
    MYSQL.Close()
Beispiel #32
0
def mysql_scheduler():
    t = time.strftime('%Y-%m-%d', time.localtime())
    MYSQL = Mysql.MYSQL(USER, PASSWORD, HOST, PORT, DB)

    def Run_sql(val):
        id, IP, PORT, DB = val[:4]
        CMD = val[5]
        val = Mysql.Query_sql(IP, PORT, DB, CMD)
        if val:
            val = str(val).replace("'", '')
        else:
            val = 'None'
        cmd = "update sql_scheduler set status = '已执行' ,results = '%s' where id = '%s';" % (
            val, id)
        loging.write(cmd, log_path=log_path)
        MYSQL.Run(cmd)
        MYSQL.Close()

    try:
        cmd = "select * from sql_scheduler where status = '未执行' and time = '%s';" % t
        values = MYSQL.Run(cmd)
        MYSQL.Close()
        if values:
            # 并发执行
            POOLS = Third_pool(10)
            POOLS.map_async(Run_sql, values)
            POOLS.close()
            POOLS.join()
    except Exception as e:
        loging.write(e, log_path=log_path)
Beispiel #33
0
 def __init__(self, keyword, num, offset=0):
     self._keyword = urllib.quote(keyword)
     self._num = num
     self._contentTool = ContentTool.ContentTool()
     self._offset = offset
     self._urls = []
     self.Mysqldb = Mysql.tomsql()
Beispiel #34
0
def Async_log(user,url):
    if 'op.baihe.com' in url:
        mysql_op_log = Mysql.mysql_op(user, url)
        Proc = Pool()
        def Run():
            mysql_op_log.op_log()
        Proc.apply_async(Run)
        Proc.close()
        Proc.join()
def deduct_daily(now, instanceid, unit_price, userid, instancename):
	sql = "update user_pay set updatetime = '%s' where instanceid = '%s'" % (now, instanceid)
	Mysql.updateData(sql)
	sql = "update user set account = account - '%s' where userid = '%s'" % (unit_price, userid)
	Mysql.updateData(sql)	
	sql = "insert into user_info (userid, instanceid, instancename, op, money, time) values ('%s', '%s', '%s', '-', '%s', '%s')" % (userid, instanceid, instancename, unit_price, now)
	Mysql.insertData(sql)
    def click(self):
        ad = self.lineEdit.text()
        sifre = self.lineEdit_2.text()
        u=User.User(ad,sifre,"")
        print("user oluşturuldu")

        if Mysql.getir(u):
            if self.checkBox.isChecked():
                from anasayfa import AnaSayfa
                self.anasayfa=AnaSayfa()
                self.anasayfa.show()
            basla=TarayiciTaramaBaslat(self)

        else:
            print ("basarisiz")
def get_user_pay():
	sql = "select * from user_pay"
	rows = Mysql.selectData(sql)
	now1 = get_current_date()
	now = datetime.datetime.fromtimestamp(now1)
	adminid = 'dff7def8e5314b2c8df8b2d639c666f5'
#	print "this is now:: '%s'" % now
	for row in rows:
	    if row['userid'] != adminid:	
#		print "this is row.time: '%s'" % row['updatetime']
		updatetime = row['updatetime']
		dd = now - updatetime
#		print "this is '%s' dd : '%s'" % (row['instancename'], dd)
#		print "this is dd.days: '%s'" % dd.days
#		print "this is dd.seconds : '%s'" % dd.seconds
#		print "this is time difference: '%s'" % dd
#		print "this is time.days:: '%s'" % dd.days	
#		print "this is time.seconds:: '%s'" % dd.seconds
#		account = get_current_account(row['userid'])
		u = get_user(row['userid'])	
#		print "this is u.accont : '%s'" % u.account
#		print "this is row['unit_price'] : %s'" % row['unit_price']
		
		if row['status'] == '1':	
#			print "trrrrrr"
			if u.account >= row['unit_price']:
				if (dd.days == 1) and (dd.seconds >= 0) and (dd.seconds <= 800):
#					print "true"
					deduct_daily(now, row['instanceid'], row['unit_price'], row['userid'], row['instancename'])
			else:
				status = '2'
				set_status(instanceid, status)
		if row['status'] == '2':
			if u.account >= row['unit_price']:
				deduct_daily(now, row['instanceid'], row['unit_price'], row['userid'], row['instancename'])		
		
				status = '1'				
				set_status( row['instanceid'], status)
			else:
				if (dd.days == 3) and (dd.seconds >= 0) and (dd.seconds <= 800):
					status = '3'
					set_status(row['instanceid'], status)
					
					delete_instance(u, row['instanceid'])
	def Seleccionar(self):
			self.table.setRowCount(0)
			self.table.setColumnCount(0)
			self.table.setColumnCount(3)
			self.table.setColumnWidth(0,700)
			self.table.setColumnWidth(1,200)
			self.table.setColumnWidth(2,200)
			self.table.setHorizontalHeaderLabels(["girilen siteler","tarih","browser"])
			row = 0
			query = Mysql.gecmisGetir()
			for q in query:
				self.table.insertRow(row)

				url = QTableWidgetItem(str(q[0]))
				ad=QTableWidgetItem(str(q[2]))
				tarih=QTableWidgetItem(str(q[1]))

				self.table.setItem(row, 0, url)
				self.table.setItem(row, 1, tarih)
				self.table.setItem(row, 2, ad)
				row = row + 1
def set_status(instanceid, status):
	sql = "update user_pay set status = '%s' where instanceid = '%s'" % (status, instanceid)
	Mysql.updateData(sql)
Beispiel #40
0
 def getJson(file):
     NewsJson = Mysql.select_data(file,NewsJsonCursor)
     b = json.dumps(NewsJson,indent=4 * ' ')
     return b
def get_user(userid):
	sql = "select * from user where userid = '%s' " % userid
	temp =  Mysql.selectData(sql)
	u = user(temp[0]['userid'], temp[0]['username'], temp[0]['password'], temp[0]['tenantid'], temp[0]['account'])
	return u