Esempio n. 1
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
Esempio n. 2
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)
Esempio n. 3
0
    def __init__(self, cpf, password, salvarArquivosBD=False):
        self._cpf = str(cpf)
        self._mysql = Mysql.Mysql(user='******' + cpf, password=str(password))
        self._autenticarStorage()

        if salvarArquivosBD:
            self._salvarArquivosBD()
        else:
            self.carregarDossies()
Esempio n. 4
0
    def __init__(self):

        self._db_connection = Mysql.Mysql()
        self._manager = multiprocessing.Manager()

        self._queue = self._manager.Queue()
        self._lock = self._manager.Lock()

        self._pool = multiprocessing.Pool(8)

        self._timer = OuTimer.Timer(5,
                                    MainServer._handle_task,
                                    args=(self._queue, self._lock))
        self._timer.start()

        # Use signal handler to throw exception which can be caught
        # by worker process to allow graceful exit.
        Daemonize.signal()
Esempio n. 5
0
def worker_proc(q, l):
    """

    :type q: multiprocessing.Manager.Queue
    :type l: multiprocessing.Manager.Lock
    """
    print "111111"

    data = q.get()
    print data
    # print "%s" % (data,)
    # if data is None:
    #    return
    mysql = Mysql.Mysql()

    row = mysql.getOne("select * from cps_shop where nick='妙乐乐官方旗舰店'")

    print row
Esempio n. 6
0
def data_business():
    """"""
    try:
        mysqlobj = Mysql.Mysql()
        mysqlobj = mysqlobj.db_connect()
        codeRootdir = cur_file_dir()
        try:
            with open(codeRootdir + "/json/sql.json", "r") as f:
                sql_dict = json.loads(f.read())
        except BaseException, e:
            print e
            if sql_dict.has_key("sql"):
                command = sql_dict["sql"]
                dataobj = mysqlobj.db_query(command)
                with open("business_data.txt", "w+") as f:
                    # f.writelines(date_time)
                    f.writelines(dataobj)
                    f.write('\n')
                    return "The business data query was successful"
            else:
                print "sql.json is none"
                return "sql.json is none"
    except BaseException, e:
        print e
Esempio n. 7
0
#!/usr/bin/env python
# coding=utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import requests
from bs4 import BeautifulSoup
import re
import json
import Mysql
from collections import OrderedDict

mysql = Mysql.Mysql()


# 保存到 mysql
def save_mysql(table, dict):
    mysql.insertData(table,dict)

def get_one_page(url):
    wb_data = requests.get(url)
    wb_data.encoding = wb_data.apparent_encoding
    return  wb_data.text
    #if wb_data.status_code == 200:
        #return wb_data.text
    #else:
        #return None


def parse_one_page(html):
    soup = BeautifulSoup(html, 'lxml')
Esempio n. 8
0
def getSeries():

    mysql = Mysql.Mysql()
    # 3201084051 コミック
    lines = mysql.getCategoryProduct("3201084051")

    lineLen = len(lines)

    title = ""
    titleNum = 0

    nextTitle = ""
    nextTitleNum = 0
    num = 0

    seriesTitle = ""
    seriesPublisher = ""
    seriesFlg = 0
    seriesMinNum = 99999
    seriesMinAsin = ""
    seriesMaxNum = 0
    seriesCount = 1

    totalInstCount = 0
    totalUpdtCount = 0
    totalProcCount = 0

    #
    itemLine = {}

    while num < lineLen:
        line = lines[num][0]  #title
        asin = lines[num][1]  #asin

        #print (line)
        title, titleNum = findNumber(line)
        # 巻数が存在する場合
        if (titleNum != 0 and (num + 1) < lineLen):
            nextLine = lines[num + 1][0]
            nextAsin = lines[num + 1][1]

            nextTitle, nextTitleNum = findNumber(nextLine)
            #print (nextTitle , nextTitleNum)

            # 次のタイトルと一致するか確認 一致する場合
            if (title == nextTitle):
                #print ("itti!!!!")
                seriesTitle = title
                seriesFlg = 1
                # 最小最大巻数を工数(次の巻数分も更新する)
                if (seriesMinNum > titleNum):
                    seriesMinNum = titleNum
                    seriesMinAsin = asin
                if (seriesMinNum > nextTitleNum):
                    seriesMinNum = nextTitleNum
                    seriesMinAsin = nextAsin
                if (seriesMaxNum < titleNum):
                    seriesMaxNum = titleNum
                if (seriesMaxNum < nextTitleNum):
                    seriesMaxNum = nextTitleNum

                seriesCount += 1
                num += 1
                continue

        if (seriesFlg == 1):
            print(" タイトル:" + seriesTitle + " | " + " 巻数" + str(seriesMinNum) +
                  "~" + str(seriesMaxNum) + "計" + str(seriesCount))
        else:
            seriesTitle = title
            seriesMinAsin = asin
            #print (" タイトル:" + seriesTitle + " | "  + " 巻数" + str(seriesMinNum) + "~" + str(seriesMaxNum) + "計" + str(seriesCount))

        itemLine["min_asin"] = seriesMinAsin
        itemLine["series_title"] = seriesTitle
        itemLine["series_min"] = seriesMinNum
        itemLine["series_max"] = seriesMaxNum
        itemLine["series_count"] = seriesCount

        instCount = mysql.updateSeriesInfo(itemLine)
        totalProcCount += 1

        if ((totalProcCount % 300) == 0):
            time.sleep(0.1)
        time.sleep(0.01)

        if instCount == 1:
            totalInstCount += 1
        else:
            totalUpdtCount += 1

        #変数初期化
        itemLine = {}
        seriesFlg = 0
        seriesCount = 1
        seriesTitle = ""
        seriesMinAsin = ""
        seriesMaxNum = 0
        seriesMinNum = 99999

        #次のレコードに遷移
        num += 1

    print("db update finish! total:" + str(totalInstCount + totalUpdtCount) +
          " new:" + str(totalInstCount) + " update:" + str(totalUpdtCount))
Esempio n. 9
0
 def __init__(self):
     self.database = Mysql.Mysql()
Esempio n. 10
0
 def __init__(self, listurl, listname='Billboard'):
     self.URL = listurl
     self.listname = listname
     self.mysql = Mysql.Mysql()