-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate_epub_clean.py
executable file
·40 lines (30 loc) · 1.11 KB
/
validate_epub_clean.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import os, filecmp, shutil, time
import subprocess
BASE_DIR = "/home/content/uploaded/epubs"
ignore_dirs = []
ignore_dirs.append(BASE_DIR)
#ignore_dirs.append(os.path.join(BASE_DIR,'clean'))
ignore_dirs.append(os.path.join(BASE_DIR,'warning'))
ignore_dirs.append(os.path.join(BASE_DIR,'error'))
ignore_dirs.append(os.path.join(BASE_DIR,'error/accept'))
ignore_dirs.append(os.path.join(BASE_DIR,'error/reject'))
def run(cmd):
call = ["/bin/bash", "-c", cmd]
ret = subprocess.call(call, stdout=f, stderr=f)
file_list = []
for dirpath, dirnames, filenames in os.walk(BASE_DIR):
if dirpath not in ignore_dirs:
for files in filenames:
file_list.append(os.path.join(dirpath,files))
counter = 0
f = open('/home/content/uploaded/epubcheck-3.0/clean.log', 'w')
for files in file_list:
raw_path,raw_name = os.path.split(files)
raw_base,raw_ext = os.path.splitext(raw_name)
base = raw_base.lower()
ext = raw_ext.lower()
counter += 1
if ext == '.epub':
run("java -jar /home/mhare/uploaded/epubcheck-3.0/epubcheck-3.0.jar " + files)
f.close()