コード例 #1
0
ファイル: Hasher.py プロジェクト: Yanixos/sic
def HashDir(dir, table_name, hasher, verbose, update_check):

    total_paths = 0
    if update_check == 1:
        fwa = open('/usr/share/sic/ActualBase.list', 'a')
        os.chmod('/usr/share/sic/ActualBase.list', 0o600)
    else:
        update = True
        fw = open('/usr/share/sic/.DirArchi/.' + table_name, 'w')
        os.chmod('/usr/share/sic/.DirArchi/.' + table_name, 0o600)
    for rootDir, subDirs, subFiles in os.walk(dir):

        for i in range(0, len(subFiles)):
            f = str(rootDir) + '/' + str(subFiles[i])
            total_paths += 1

            if '.log' in f or 'log/' in f or 'spool/' in f or 'history' in f or 'cache' in f or '/var/lib' in f or 'mtab' in f or 'backup' in f or 'subscriptions.conf' in f or '/etc/resolv.conf' in f or 'mail' in f:
                pass
            else:
                try:
                    hash = HashFile(f, hasher)
                except Exception as e:
                    pass
                row = FileAttributes(hash, f, table_name)
                if update_check == 0:
                    db.insert_table(table_name, row, verbose)
                    fw.write(f + "\n")
                else:
                    fwa.write(str(row)[1:-1] + "\n")
    if update_check == 1:
        fwa.close()
    else:
        fw.close()

    return total_paths
コード例 #2
0
def process_files():
    '''For each file in the local folder, run pipeline.'''
    import traceback, sys
    directory = r'C:\Users\Kik\Documents\GitHub\argo_ocean_data_analysis\helper'
    for daily_file in os.listdir(directory):
        if daily_file.endswith(".nc"):
            success = False
            while not success:
                try:
                    myobject = argo_manipulation(fname=daily_file,
                                                 fdate=daily_file)
                    myobject.manipulation_pipeline()
                    if len(myobject.argo_df) > 0:
                        insert_table("ocean_data", myobject.argo_df)
                        print(f"Inserted {daily_file} into ocean_data")
                    else:
                        print(f"No data in {daily_file} - not inserted in db")
                    success = True

                except Exception as e:
                    traceback.print_exc(file=sys.stdout)
                    print(f"{daily_file} not written to db")
                    time.sleep(1)
        else:
            pass
コード例 #3
0
ファイル: orm.py プロジェクト: hujingguang/Study4Blog
 def insert(self):
     L=[]
     args={}
     for k,v in self.__mapping__.iteritems():
         if v.insertable:
             if not hasattr(self,k):
                 setattr(self,k,v.default)
             args[k]=getattr(self,k)
     db.insert_table(self.__table__,**args)
コード例 #4
0
	def get_weather(self, dict_info):
		result = self.weather_api.consult_weather.call_async(dict_info)
		
		if result.result():
			dict_result = result.result()
			dict_result['city'] = dict_info["city"].lower()
			dict_result['country'] = dict_info["country"].lower()
	
			insert_table(dict_result)
	
		return result.result()
		
		
def conectado(con, cliente):
    print('Conectado por', cliente)
    conec = db.connection()
    while True:
        dados_list = con.recv(1024).decode().split(' ')
        if dados_list[0] == 'STOP':
            print('Finalizando conexão com', cliente)
            break

        db.insert_table(conec, dados_list[1], dados_list[3], dados_list[5])
        db.select_table(conec)  #exibe os dados do banco
        print(
            "Dados recebidos: Nome-> {} / Celular-> {} / Telefone-> {}".format(
                dados_list[1], dados_list[3], dados_list[5]))
        aviso = "Dados foi inserido no banco"
        con.sendall(aviso.encode())
コード例 #6
0
ファイル: dbhelper.py プロジェクト: linzelong/zhihu-archive
def saveUser(username, nickname):
    user_id = get_user_id_by_name(username)
    update = {'name': username, 'nick_name': nickname}
    if user_id is None:
        return db.insert_table('user', update)
    else:
        return db.update_table('user', update, {'name': username})
コード例 #7
0
ファイル: dbhelper.py プロジェクト: linzelong/zhihu-archive
def saveQuestion(qid, question, description):
    question_id = get_question_by_id(qid)
    args = {
        'id': qid,
        'title': question,
        'description': description,
        'fetch_time': int(time.time()),
        'fetch': 0
    }
    if question_id is None:
        return db.insert_table('question', args)
    else:
        return db.update_table('question', args, {'id': qid})
コード例 #8
0
ファイル: dbhelper.py プロジェクト: linzelong/zhihu-archive
def _saveAnswer(aid, qid, username, content, vote):
    user_id = get_user_id_by_name(username)
    if user_id is None:
        raise Exception('no user {}'.format(username))
    args = {
        'id': aid,
        'q_id': qid,
        'user_id': user_id,
        'text': content,
        'vote': vote,
        'fetch_time': int(time.time())
    }
    return db.insert_table('answer', args)
コード例 #9
0
ファイル: webapp.py プロジェクト: yiqunzheng/fraud-detection
def score():
    test = [request.get_json()]
    X_xgb, xgb_preds = predict(test, xgb_model)
    insert_table(X_xgb, xgb_preds, table)
    print str(xgb_preds)
    return ''
コード例 #10
0
ファイル: test.py プロジェクト: Ashwinigunjal/cruid
            print "please enter value 1-6"

        else:
            if (val == 1):
                print "create table"
                table_name = raw_input("enter table name: ")
                db.create_table(table_name)

            elif (val == 2):

                name = raw_input("Enter name: ")
                place = raw_input("Enter your place: ")
                mobile_no = raw_input("Enter mobile number: ")
                year = raw_input("Enter year: ")
                branch = raw_input("Enter your branch: ")
                db.insert_table(name, place, mobile_no, year, branch)
                print "add record"

            elif (val == 3):
                print "display record"
                db.display_data()

            elif (val == 4):
                print "search data"
                idd = input("Enter user id: ")
                db.search_by_id(idd)

            elif (val == 5):
                print "del data by id"
                idd = input("Enter user id: ")
                db.delete_data(idd)
コード例 #11
0
ファイル: dbhelper.py プロジェクト: linzelong/zhihu-archive
def insert_user(args):
    user_id = db.insert_table('user', args)
    print('user_id', user_id)
    return user_id