Skip to content

Commit

Permalink
added add_arguments method now required by Django 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jay7958 committed Sep 8, 2015
1 parent 4e3d77e commit 6839943
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
12 changes: 8 additions & 4 deletions dojo/management/commands/notify_isoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@
class Command(BaseCommand):
help = "Details: Spams External Unit\nArgs: Weekly, Monthly, Quarterly"

def add_arguments(self, parser):
parser.add_argument('type')

def handle(self, *args, **options):
type = options['type']

if not args:
if not options:
print "Must specify an argument: Weekly, Monthly, or Quarterly"
sys.exit(0)
if args[0] not in ["Weekly", "Monthly", "Quarterly"]:
print("Unexpected frequency: " + str(args[0]) +
if type not in ["Weekly", "Monthly", "Quarterly"]:
print("Unexpected frequency: " + str(type) +
"\nMust specify an argument: Weekly, Monthly, or Quarterly.")
sys.exit(0)

scSettings = ScanSettings.objects.filter(frequency=args[0])
scSettings = ScanSettings.objects.filter(frequency=type)

scan_start_time = datetime.datetime.today() + datetime.timedelta(
hours=12)
Expand Down
16 changes: 10 additions & 6 deletions dojo/management/commands/run_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class Command(BaseCommand):
help = "Details:\n\tRuns nmap scans\n\nArguments:" +\
"\n\tWeekly\n\tMonthly\n\tQuarterly"

def add_arguments(self, parser):
parser.add_argument('type')

def handle(self, *args, **options):
type = options['type']

# Scan the host and add the results of the scan to the host informaiton
def runScan(prod_id, p_dict):
Expand Down Expand Up @@ -195,23 +199,23 @@ def run(self):
Scans are performed on a Weekly, Monthly, or Quarterly bases. The
target frequency is specified by the cron job scheduler.
"""
if not args:
if not options:
print "Must specify an argument: Weekly, Monthly, Quarterly, or ID",\
" of Scan Settings to use."
sys.exit(0)
if (args[0] in ["Weekly", "Monthly", "Quarterly"]
or args[0].isdigit()):
if (type in ["Weekly", "Monthly", "Quarterly"]
or type.isdigit()):
pass
else:
print("Unexpected parameter: " + str(args[0]))
print "\nMust specify an argument: Weekly, Monthly, Quarterly",\
" or ID of Scan Settings to use."
sys.exit(0)

if args[0].isdigit():
scSettings = ScanSettings.objects.filter(id=args[0])
if type.isdigit():
scSettings = ScanSettings.objects.filter(id=type)
else:
scSettings = ScanSettings.objects.filter(frequency=args[0])
scSettings = ScanSettings.objects.filter(frequency=type)

if len(scSettings) <= 0:
print("No scan settings found with parameter specified.")
Expand Down

0 comments on commit 6839943

Please sign in to comment.