Esempio n. 1
0
def init():
    '''
		This function initializes the database
	'''
    collection = connectMongo()
    collection.remove()
    print('Database reinitialized')
Esempio n. 2
0
def init():
    collection = connectMongo()
    collection.remove()

    with open('initial.json') as json_file:
        json_object = json.load(json_file)

    for data in json_object:
        collection.insert(data)

    print('Database reinitialized')
Esempio n. 3
0
# Project 1 Task 1
# due 10/6/2017

# Carsten Hood
# UIN: 922009787
# CSCE 489-599 Cloud Computing
# Fall 2017

from mongo_connect import connectMongo
import constants
import pymongo
import json
import pprint
import redis

collection = connectMongo()

##### FIND ALL ENTRIES IN THE DATABASE #####
# Assuming RQ0 is the query to find all entries in the database
RQ0 = collection.find()
for data in RQ0:
    pprint.pprint(data)

pprint.pprint("hello")

######## FIND ENTRIES WITH CONDITION #######
######## collection.find(CONDITION) #######
######## E.g., collection.find({"Name" : "Alice"}) #######

######## UPDATE ENTRIES WITH CONDITION ########
######## collection.update_one(CONDITION, _update_) #######
Esempio n. 4
0
        }
    }, {
        '$project': {
            'uid': 1,
            'total_activity_duration': {
                '$ifNull': ['$total_activity_duration', 0]
            }
        }
    }]

    res = collection.aggregate(pipeline)
    for doc in res:
        pprint(doc)


targetCollection = connectMongo()

# # WQ1. Add the data in dummy-fitness.json to the MongoDB database
# # insert documents in json file into collection
# insertJsonFile(fname='dummy-fitness.json', collection=targetCollection)

# # WQ2. Update the database with data from user1001-new
# # read the json
# with open("user1001-new.json") as f:
#     jsonObject = json.load(f)
#
# # update the document with uid 1001
# updateEmployeeInfo(targetCollection, jsonObject)

# # RQ1. Count the number of employees whose data is in the AggieFit database.
# print current number of employees in database
Esempio n. 5
0
from mongo_connect import connectMongo
from redis_connect import connectRedis
import constants
import pymongo
from pymongo import errors as pymonerr

messageboarddb = connectMongo()

redis_pub = connectRedis()
redis_sub = redis_pub.pubsub()
# redis_sub.subscribe("test-redispy")
Esempio n. 6
0
 def __init__(self):
     self.db = connectMongo()
     self.userFeatures = self.db['user_features']
     self.weights = self.db['weights']
     self.userAverageScores = self.db['averageScore']
Esempio n. 7
0
from fuzzy_hash import sdhash_get_from_file
from virus_check import clamav  # take file path, return True for ok, False for virus
import os
from mongo_connect import connectMongo

CONTENT_GOOD = 1
CONTENT_SUSPICIOUS = 2

files_sdhashs = connectMongo()

md = clamav()


def virus_check_file(file_path):
    ret = md.scan_file(file_path)
    return ret


def global_process_files(_file_paths_list):
    num_all_files = len(_file_paths_list)
    num_bad_files = 0
    suspicious_file_paths_list = []
    for file_path in _file_paths_list:
        head, file_name_with_ext = os.path.split(file_path)  # with ext
        sdhash = sdhash_get_from_file(file_path)
        if global_check_file(file_name_with_ext, sdhash,
                             file_path) == CONTENT_GOOD:
            print("One file passed global test")
        else:
            suspicious_file_paths_list.append(file_path)
            num_bad_files += 1
Esempio n. 8
0

def printdict(dict):
    print("{"),
    i = 0
    for key, value in dict.iteritems():
        i = i + 1
        if (str(key) != "_id"):
            if i < len(dict):
                print("'" + str(key) + "':'" + str(value) + ", "),
            else:
                print("'" + str(key) + "':'" + str(value)),
    print("}")


db = connectMongo()
#db.create_collection("health_quotes")
#db.create_collection("fit_chat")
allcollectionNames = db.collection_names()
#db["health_quotes"].remove()
#db["fit_chat"].remove()
#for collectionName in allcollectionNames:
#	print(collectionName)
selectCollection = False
listenStart = False
previndex = 0
while True:
    try:
        if listenStart == True:
            while True:
                if previndex != msgboard.count():