@@ -13,17 +13,14 @@ _First of all: provide some arguments in the `main.py` file to collect informati
13
13
14
14
To run the framework:
15
15
``` bash
16
- python3 main.py
16
+ python3 main.py example_scenario.yaml
17
17
```
18
18
To run the tests:
19
19
``` bash
20
20
chmod +x run_tests.sh
21
21
./run_tests.sh
22
22
```
23
- _ or you can run them like this, of course:_
24
- ``` bash
25
- python3 -m unittest discover -v
26
- ```
23
+
27
24
## Running as a separated module
28
25
Basic:
29
26
``` python3
@@ -51,10 +48,11 @@ Use the following structure:
51
48
2 . Provide the following structure of your script directory:
52
49
```
53
50
your_script_name
54
- ├── __init__.py - use this module to set the default parent directory (you can copy this file from any other script)
55
- ├── __main__.py - use this module to provide some basic interface to use your script as a module (the same as if __name__ == "__main__")
56
- ├── module.py - use this module to describe the basic logic of your module (you can import it in the __main__.py to provide interface)
57
- └── test_module.py - use this module for unittest tests
51
+ ├── requirements.txt - provide required libraries
52
+ ├── __init__.py - use this module to set the default parent directory (you can copy this file from any other script)
53
+ ├── __main__.py - use this module to provide some basic interface to use your script as a module (the same as if __name__ == "__main__")
54
+ ├── module.py - use this module to describe the basic logic of your module (you can import it in the __main__.py to provide interface)
55
+ └── test_module.py - use this module for unittest tests
58
56
```
59
57
3 . Create the ` __init__.py ` file. An example of the ` __init__.py ` boilerplate structure can be seen below:
60
58
``` python3
@@ -103,6 +101,9 @@ class Runner(OsintRunner):
103
101
"""
104
102
Basic script example
105
103
"""
104
+
105
+ # Define required arguments here
106
+ required = [" my_argument" ]
106
107
107
108
def __init__ (self , logger : str = __name__ ):
108
109
"""
@@ -114,6 +115,7 @@ class Runner(OsintRunner):
114
115
"""
115
116
super (Runner, self ).__init__ (logger)
116
117
118
+ # Validate input arguments (if you need some validation)
117
119
@validate_kwargs (PossibleKeys.KEYS )
118
120
def run (self , * args , ** kwargs ) -> ScriptResponse.success or ScriptResponse.error:
119
121
"""
@@ -126,6 +128,7 @@ class Runner(OsintRunner):
126
128
:return: ScriptResponse message (error or success)
127
129
"""
128
130
argument = kwargs.get(" my_argument" , " Arguments were not provided!" )
131
+ ...
129
132
return ScriptResponse.success(message = f " Script finished with argument { argument} " )
130
133
```
131
134
6 . For ` test_module.py ` you can use any required tests (as you wish). A test case for your module is required to keep the project clean.
0 commit comments