28 lines
545 B
Python
28 lines
545 B
Python
|
|
import os, glob, logging
|
||
|
|
from db import db
|
||
|
|
import config
|
||
|
|
|
||
|
|
logging.basicConfig(level=logging.DEBUG)
|
||
|
|
|
||
|
|
def list_all(d, ext):
|
||
|
|
|
||
|
|
if not os.path.isdir(d):
|
||
|
|
logging.error(d + " is not a valid directory.")
|
||
|
|
return None
|
||
|
|
|
||
|
|
return [f for f in glob.glob(os.path.join(d, "*." + ext))]
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
|
||
|
|
db = db.DB(config.list_server_busy_db)
|
||
|
|
|
||
|
|
db.create_db()
|
||
|
|
|
||
|
|
xml_files = list_all(config.xml['path'], 'xml')
|
||
|
|
|
||
|
|
urls_index_file = os.path.join(config.index['path'], config.index['urls'])
|
||
|
|
for x in xml_files:
|
||
|
|
db.insert_db(x, urls_index_file)
|
||
|
|
|