Skip to content

Commit

Permalink
Added: single entrypoint for program
Browse files Browse the repository at this point in the history
  • Loading branch information
agamdua committed Mar 12, 2020
1 parent 00a0aff commit 1dec7b2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 45 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,22 @@ pip install -r requirements.txt
### CLI

```
$ python ileapp.py --help
Usage: ileapp.py [-h] pathtodir
iLEAPP: iOS Logs, Events, and Preferences Parser.
$ python ileapp.py <path_to_image>
```

positional arguments:
pathtodir Path to directory
### GUI

optional arguments:
-h, --help show this help message and exit
```
$ python ileapp.py --gui
```

### GUI
### Help

```
$ python ileappGUI.py
$ python ileapp.py --help
```


The GUI will open in another window.


Expand Down
27 changes: 20 additions & 7 deletions ileapp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import sys
from time import process_time

from extraction import *
Expand All @@ -7,14 +8,26 @@
parser = argparse.ArgumentParser(
description="iLEAPP: iOS Logs, Events, and Preferences Parser."
)
parser.add_argument("pathtodir", help="Path to directory")
parser.add_argument("pathtodir", nargs='?', help="Path to directory")
parser.add_argument("--gui", action="store_true", help="To run program with the GUI client")

args = parser.parse_args()
pathto = args.pathtodir
image_fpath = args.pathtodir
gui = args.gui

start = process_time()
log = pre_extraction(pathto)
if sum([gui, bool(image_fpath)]) < 1:
print("[ERROR] Please provide at least one argument. Run `$ python ileapp.py -h` for help")
sys.exit(1)

if gui:
import PySimpleGUI as sg
from ileappGUI import layout, gui_event_loop
window = sg.Window("iLEAPP", layout)
gui_event_loop(window)

extracttype = get_filetype(pathto)
extract_and_process(pathto, extracttype, tosearch, log)
running_time = post_extraction(start, extracttype, pathto)

start = process_time()
log = pre_extraction(image_fpath)
extracttype = get_filetype(image_fpath)
extract_and_process(image_fpath, extracttype, tosearch, log)
running_time = post_extraction(start, extracttype, image_fpath)
56 changes: 28 additions & 28 deletions ileappGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from settings import report_folder_base


sg.theme("DarkAmber") # Add a touch of color
# All the stuff inside your window.

sg.theme("DarkAmber") # Add a touch of color
layout = [
[
sg.Text("iOS Logs, Events, And Properties Parser.", font=("Helvetica", 25))
Expand Down Expand Up @@ -64,38 +64,38 @@


# Create the Window
window = sg.Window("iLEAPP", layout)

# Event Loop to process "events" and get the "values" of the inputs
while True:
event, values = window.read()
if event in (None, "Close"): # if user closes window or clicks cancel
break
def gui_event_loop(window):
while True:
event, values = window.read()
if event in (None, "Close"): # if user closes window or clicks cancel
break

pathto = values['Browse'] or values['Browse0']
pathto = values['Browse'] or values['Browse0']

extracttype = get_filetype(pathto)
start = process_time()
log = pre_extraction(pathto, gui_window=window)
extract_and_process(pathto, extracttype, tosearch, log, gui_window=window)
running_time = post_extraction(start, extracttype, pathto)

if values[2] == True:
extracttype = get_filetype(pathto)
start = process_time()
window.refresh()
logfunc("")
logfunc(f"CSV export starting. This might take a while...")
window.refresh()
html2csv(report_folder_base)
log = pre_extraction(pathto, gui_window=window)
extract_and_process(pathto, extracttype, tosearch, log, gui_window=window)
running_time = post_extraction(start, extracttype, pathto)

if values[2] == True:
start = process_time()
window.refresh()
logfunc("")
logfunc(f"CSV export starting. This might take a while...")
window.refresh()
html2csv(report_folder_base)

if values[2] == True:
end = process_time()
time = start - end
logfunc("CSV processing time in secs: " + str(abs(time)))
if values[2] == True:
end = process_time()
time = start - end
logfunc("CSV processing time in secs: " + str(abs(time)))

locationmessage = "Report name: " + report_folder_base + "index.html"
sg.Popup("Processing completed", locationmessage)
locationmessage = "Report name: " + report_folder_base + "index.html"
sg.Popup("Processing completed", locationmessage)

basep = os.getcwd()
webbrowser.open_new_tab("file://" + basep + base + "index.html")
sys.exit()
basep = os.getcwd()
webbrowser.open_new_tab("file://" + basep + base + "index.html")
sys.exit()

0 comments on commit 1dec7b2

Please sign in to comment.