Beispiel #1
0
def test():
    sc("rm data/test_res.json && touch data/test_res.json")
    with open("data/product.json", "r") as file:
        data = json.load(file)

    rejected, accepted = [], []

    for prod in data:
        if accurate("pins animators aurore", prod):
            accepted.append(prod['Name'])

        else:
            rejected.append(prod['Name'])

    data = {
        'accepted': accepted,
        'rejected': rejected,
        'total': {
            'accepted': len(accepted),
            'rejected': len(rejected)
        }
    }

    with open('data/test_res.json', 'w') as file:
        json.dump(data, file, indent=4, separators=(',', ': '))
Beispiel #2
0
def get_object(search_string):
    sc("rm data/product.json && touch data/product.json")
    sc("scrapy crawl ebay -o data/product.json -a search=\"" + search_string +
       "\"")

    with open("data/product.json", "r") as file:
        data = json.load(file)

    return data
Beispiel #3
0
from os import system as sc
from sys import argv

turn = int(argv[1])

while turn:
    sc("curl https://api.github.com/zen")
    print()
    turn -= 1
Beispiel #4
0
def dumptable(table):
    sc("mysqldump -u {} -p --opt {} > {}_{}-backup.sql".format(
        user_name, table, table, db))
Beispiel #5
0
def dumpdb():
    sc("mysqldump -u {} -p --opt {} > {}-backup.sql".format(user_name, db, db))
Beispiel #6
0
from os import system as sc
from sys import argv
import logging

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

token = "06494ef126fe6d600cf401fcec1f431966092e3a"
usr = "******"
url = "https://api.github.com/"
auth = "\"Authorization: token {}\"".format(token)

if argv[1] == "auth":
    url += "users/" + usr
    logger.debug("url = {}".format(url))
    sc("curl -i -u {}:${} {}".format(usr, token, url))

elif argv[1] == "get":
    url += argv[2] + argv[3]
    sc("curl -i {}".format(url))
Beispiel #7
0
from os import system as sc
import mysql.connector

from core.const import HOST_ADRESS, USER_NAME, PWD, DB_NAME

################# USE "retry" ALIAS TO RESTART ALL THE PROGRAM #################

MODE = "debug"  #Change the mode to delete all files from the project directory

mydb = mysql.connector.connect(host=HOST_ADRESS, user=USER_NAME, passwd=PWD)

mycursor = mydb.cursor()

mycursor.execute("DROP DATABASE " + DB_NAME)

if MODE != "debug":
    res = input("Do you really want to delete PurBeurre ? (YES/no) :")
    if res == "YES":
        sc("rm -rf ../../project_5/")

    print("purBeurre is fully deleted, thank you for trying !")
Beispiel #8
0
from os import system as sc

# Copy this script into the new dir and then execute it.

dir_left_to_create = 4

while dir_left_to_create > 0:
    dir_name = "part-" + str(dir_left_to_create)

    try:
        sc("mkdir {}".format(dir_name))
        sc("touch {}/chap-1.js && touch {}/sum.txt".format(dir_name, dir_name))

    except:
        pass

    dir_left_to_create -= 1

sc("rm quicknew.py")