Uh oh!
There was an error while loading. Please reload this page.
forked from TryCatchHCF/DumpsterFire
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestFireModule.py
More file actions
Latest commit
117 lines (94 loc) · 3.31 KB
/
Copy pathtestFireModule.py
File metadata and controls
117 lines (94 loc) · 3.31 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/python
#
# Filename: testFireModule.py
#
# Version: 1.0.1
#
# Author: Joe Gervais (TryCatchHCF)
#
# Summary:
#
# Utility script for debugging Fire modules. Executes each member method
# of the target Fire class, giving direct visibility into its operations
# prior to using it in dumpsterFireFactory's menu-driven environment.
#
# Description:
#
# The script takes two arguments - the full filepath of the Fire (in
# Python package format - see example below), and the name of the Fire
# class (note the lack of the .py suffix).
#
# Example:
#
# $ ./testFireModule.py FireModules/Websurfing/warez_sites.py
#
importos, sys, getopt, importlib, dumpsterFireFactory
# ================================================================================================
#
# Function: DebugTestFireTemplateMethods()
#
# Description: Loads the Fire class from the module path (in Python package format)
# then calls each of the Fire's member methods. Does not use any exception handling
# so that you can see the direct location and cause of any errors.
#
# ================================================================================================
defDebugTestFireTemplateMethods( fireFilepathStr ):
# Strip trailing ".py" suffix from filepath so we can convert to Python package format
fireFilepathStr=fireFilepathStr[ :-3 ]
# Convert filepath to Pythong package format
firePackagePathStr=fireFilepathStr.replace( '/', '.' )
# Break down that package path into its components so we can grab the Fire name
fireElementList=firePackagePathStr.split( "." )
# Extract Fire name
fireNameStr=fireElementList[ -1 ]
print""
print"-------------------------------------------------"
print"============= Test Fire Module ================"
print"-------------------------------------------------"
print""
print"Module Path:", firePackagePathStr
print"Fire Name:", fireNameStr
print""
print"---------- Trying to locate Fire in module path... ----------"
print""
currentFireClass=getattr( importlib.import_module( firePackagePathStr, fireNameStr ), fireNameStr )
thisFire=currentFireClass( "" )
print"---------- Calling Configure() method ----------"
print""
thisFire.Configure()
print""
print"---------- Calling Description() method ----------"
print""
print"\t Description: ", thisFire.Description()
print""
print"---------- Calling GetParameters() method ----------"
print""
parameters=thisFire.GetParameters()
print"Fire parameters: ", parameters
print""
print"---------- Calling SetParameters() method ----------"
print""
print"Setting Fire parameters: ", parameters
thisFire.SetParameters( parameters )
print""
print"---------- Calling ActivateLogging() method ----------"
print""
thisFire.ActivateLogging( True )
print""
print"---------- Calling Ignite() method ----------"
print""
thisFire.Ignite()
print""
print"DONE!"
print""
return
if__name__=="__main__":
if ( len(sys.argv) !=2 ):
print""
print"usage: testFireModule.py <filePathToFire>"
print""
print"Example: ./testFireModule.py FireModules/Websurfing/warez_sites"
print""
exit
else:
DebugTestFireTemplateMethods( sys.argv[1] )