Skip to content

Commit 6839943

Browse files
author
jay7958
committed
added add_arguments method now required by Django 1.8
1 parent 4e3d77e commit 6839943

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

dojo/management/commands/notify_isoc.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,21 @@
2020
class Command(BaseCommand):
2121
help = "Details: Spams External Unit\nArgs: Weekly, Monthly, Quarterly"
2222

23+
def add_arguments(self, parser):
24+
parser.add_argument('type')
25+
2326
def handle(self, *args, **options):
27+
type = options['type']
2428

25-
if not args:
29+
if not options:
2630
print "Must specify an argument: Weekly, Monthly, or Quarterly"
2731
sys.exit(0)
28-
if args[0] not in ["Weekly", "Monthly", "Quarterly"]:
29-
print("Unexpected frequency: " + str(args[0]) +
32+
if type not in ["Weekly", "Monthly", "Quarterly"]:
33+
print("Unexpected frequency: " + str(type) +
3034
"\nMust specify an argument: Weekly, Monthly, or Quarterly.")
3135
sys.exit(0)
3236

33-
scSettings = ScanSettings.objects.filter(frequency=args[0])
37+
scSettings = ScanSettings.objects.filter(frequency=type)
3438

3539
scan_start_time = datetime.datetime.today() + datetime.timedelta(
3640
hours=12)

dojo/management/commands/run_scan.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ class Command(BaseCommand):
2727
help = "Details:\n\tRuns nmap scans\n\nArguments:" +\
2828
"\n\tWeekly\n\tMonthly\n\tQuarterly"
2929

30+
def add_arguments(self, parser):
31+
parser.add_argument('type')
32+
3033
def handle(self, *args, **options):
34+
type = options['type']
3135

3236
# Scan the host and add the results of the scan to the host informaiton
3337
def runScan(prod_id, p_dict):
@@ -195,23 +199,23 @@ def run(self):
195199
Scans are performed on a Weekly, Monthly, or Quarterly bases. The
196200
target frequency is specified by the cron job scheduler.
197201
"""
198-
if not args:
202+
if not options:
199203
print "Must specify an argument: Weekly, Monthly, Quarterly, or ID",\
200204
" of Scan Settings to use."
201205
sys.exit(0)
202-
if (args[0] in ["Weekly", "Monthly", "Quarterly"]
203-
or args[0].isdigit()):
206+
if (type in ["Weekly", "Monthly", "Quarterly"]
207+
or type.isdigit()):
204208
pass
205209
else:
206210
print("Unexpected parameter: " + str(args[0]))
207211
print "\nMust specify an argument: Weekly, Monthly, Quarterly",\
208212
" or ID of Scan Settings to use."
209213
sys.exit(0)
210214

211-
if args[0].isdigit():
212-
scSettings = ScanSettings.objects.filter(id=args[0])
215+
if type.isdigit():
216+
scSettings = ScanSettings.objects.filter(id=type)
213217
else:
214-
scSettings = ScanSettings.objects.filter(frequency=args[0])
218+
scSettings = ScanSettings.objects.filter(frequency=type)
215219

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

0 commit comments

Comments
 (0)