1
0
Fork 0
mirror of https://github.com/Findus23/se-simulator.git synced 2024-09-19 15:53:45 +02:00
se-simulator/consume.py

31 lines
835 B
Python
Raw Normal View History

2018-03-15 21:38:18 +01:00
import glob
import os
import shutil
import subprocess
from parsexml import parse_posts, parse_comments, parse_usernames
2018-03-16 18:48:54 +01:00
from utils import *
2018-03-15 21:38:18 +01:00
# os.chdir("/mydir")
for file in glob.glob("downloads/**/*.7z"):
2018-03-16 20:31:43 +01:00
if not "raspberry" in file:
2018-03-15 21:38:18 +01:00
continue
code = os.path.basename(os.path.splitext(file)[0])
print(code)
2018-03-16 18:48:54 +01:00
currentdir = os.getcwd()
rawdir = "raw/" + code
sitesdir = "sites/" + code
for dir in [rawdir, sitesdir]:
if not os.path.exists(dir):
os.mkdir(dir)
shutil.copy2(file, rawdir)
os.chdir(rawdir)
2018-03-15 21:38:18 +01:00
print("Start extracting")
subprocess.check_output(["7z", "x", "-aoa", code + ".7z"])
2018-03-16 18:48:54 +01:00
os.chdir(currentdir)
2018-03-15 21:38:18 +01:00
print("Start parsing")
2018-03-16 18:48:54 +01:00
parse_posts(rawdir, sitesdir)
parse_comments(rawdir, sitesdir)
parse_usernames(rawdir, sitesdir)
2018-03-15 21:38:18 +01:00
print("DONE")