Example #1
0
import os
import sys
runPath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(runPath, ".."))

from dateutil.parser import parse as parse_datetime

import tarfile
import shutil

from lib.Config import Configuration
import lib.DatabaseLayer as db

vFeedurl = Configuration.getvFeedURL()
vFeedstatus = Configuration.getvFeedStatus()
tmppath = os.path.join(runPath, "..", Configuration.getTmpdir())
print(tmppath)
# check modification date
try:
    u = Configuration.getFile(vFeedurl)
except:
    sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(vFeedurl))
last_modified = parse_datetime(u.headers['last-modified'], ignoretz=True)
i = db.getLastModified('vfeed')
if i is not None:
    if last_modified == i:
        print("Not modified")
        sys.exit(0)
# create temp file and download and unpack database
if not os.path.exists(tmppath):
    os.mkdir(tmppath)
import lib.DatabaseLayer as db

try:

    r = Configuration.getRedisRefConnection()
except:
    sys.exit(1)

try:
    r.info()
except:
    sys.exit("Redis server not running on %s:%s"%(Configuration.getRedisHost(),Configuration.getRedisPort()))


RefUrl = Configuration.getRefURL()
tmppath = Configuration.getTmpdir()

argparser = argparse.ArgumentParser(description='Populate/update the NIST ref database')
argparser.add_argument('-v', action='store_true', help='verbose output', default=False)
args = argparser.parse_args()

if args.v:
    verbose = True

# check modification date
try:
    u = Configuration.getFile(RefUrl)
except:
    sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(RefUrl))
i = db.getLastModified('ref')
if i is not None:
Example #3
0
import os
import sys
runPath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(runPath, ".."))

import tarfile
import shutil
import sqlite3

from lib.ProgressBar import progressbar
from lib.Config import Configuration
import lib.DatabaseLayer as db

vFeedurl = Configuration.getvFeedURL()
vFeedstatus = Configuration.getvFeedStatus()
tmppath = os.path.join(runPath, "..", Configuration.getTmpdir())

# check modification date
try:
    u = Configuration.getFile(vFeedurl)
except:
    sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(vFeedurl))
i = db.getLastModified('vfeed')
if i is not None:
    if u.headers['last-modified'] == i:
        print("Not modified")
        sys.exit(0)
# create temp file and download and unpack database
if not os.path.exists(tmppath):
    os.mkdir(tmppath)
with open(tmppath+'/vfeed.db.tgz', 'wb') as fp:
Example #4
0
from lib.Config import Configuration
import lib.DatabaseLayer as db

try:

    r = Configuration.getRedisRefConnection()
except:
    sys.exit(1)

try:
    r.info()
except:
    sys.exit("Redis server not running on %s:%s" %
             (Configuration.getRedisHost(), Configuration.getRedisPort()))

tmppath = Configuration.getTmpdir()

argparser = argparse.ArgumentParser(
    description='Populate/update the NIST ref database')
argparser.add_argument('-v',
                       action='store_true',
                       help='verbose output',
                       default=False)
args = argparser.parse_args()

if args.v:
    verbose = True

# check modification date
try:
    (f, r) = Configuration.getFeedData('ref')