-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop_1.3.2' into 'master'
Version 1.3.2 See merge request Cyb3r-Jak3/pystalk!8
- Loading branch information
Showing
6 changed files
with
121 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,92 @@ | ||
# -*- coding: utf-8 -*- | ||
"""This script get the exif data from photos | ||
and creates graphs from the metadata""" | ||
|
||
import argparse | ||
import os | ||
import logging | ||
import sys | ||
from exif import Image | ||
import utils | ||
import modules | ||
|
||
|
||
def main(): | ||
""" This main function""" | ||
parser = argparse.ArgumentParser(prog="PyStalk", | ||
description="Tool to graph " | ||
"image metadata.") | ||
parser.add_argument('files', nargs='*', default=None, | ||
help='Path of photos to check.') | ||
parser.add_argument('-t', '--test', default=False, action="store_true", | ||
help='Does not show the graphs at the end.') | ||
# Logging function from https://stackoverflow.com/a/20663028 | ||
parser.add_argument('-d', '--debug', help="Sets logging level to DEBUG.", | ||
action="store_const", dest="loglevel", | ||
const=logging.DEBUG, default=logging.WARNING) | ||
parser.add_argument("-v", "--verbose", help="Sets logging level to INFO", | ||
action="store_const", dest="loglevel", | ||
const=logging.INFO) | ||
args = parser.parse_args() | ||
|
||
log = utils.make_logger("PyStalk", args.loglevel) | ||
log.info("Starting up") | ||
|
||
if not args.files: | ||
log.error("WARNING: No path was inputted. " | ||
"This will cause the script to break") | ||
sys.exit(1) | ||
|
||
for path in args.files: | ||
isdir = os.path.isdir(path) | ||
log.debug("Detected path as a directory") | ||
|
||
photos = [] | ||
invalid_photos = [] | ||
|
||
if isdir: | ||
for f in os.listdir(args.files[0]): | ||
with open(os.path.join(args.files[0], f), 'rb') as raw_photo: | ||
try: | ||
exif_image = Image(raw_photo) | ||
if exif_image.has_exif: | ||
photos.append(os.path.join(args.files[0], f)) | ||
else: | ||
invalid_photos.append(os.path.join(args.files[0], f)) | ||
except AssertionError: | ||
log.warning("Error with %s", raw_photo) | ||
else: | ||
for x, item in enumerate(args.files): | ||
with open(item, 'rb') as raw_photo: | ||
try: | ||
exif_image = Image(raw_photo) | ||
if exif_image.has_exif: | ||
photos.append(args.files[x]) | ||
log.debug("%s has exif data", item) | ||
else: | ||
invalid_photos.append(args.files[x]) | ||
except AssertionError: | ||
log.warning("Error with %s", raw_photo) | ||
|
||
plots = { | ||
"STATS": modules.Stats(photos, invalid_photos, log), | ||
"GPS": modules.GPS_Check(photos, log), | ||
"Timestamp": modules.date_time(photos, log), | ||
"Model": modules.PieChart(photos, "Model", log), | ||
"Flash": modules.PieChart(photos, "Flash", log), | ||
"Focal": modules.PieChart(photos, "Focal", log), | ||
"Software": modules.PieChart(photos, "Software", log) | ||
} | ||
|
||
utils.graph(plots, log, args.test) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
# -*- coding: utf-8 -*- | ||
"""This script get the exif data from photos | ||
and creates graphs from the metadata""" | ||
|
||
import argparse | ||
import os | ||
import logging | ||
import sys | ||
import timeit | ||
from exif import Image | ||
import utils | ||
import modules | ||
|
||
start = timeit.default_timer() | ||
|
||
|
||
def setup(): | ||
""" Sets up PyStalk and parses arguments""" | ||
parser = argparse.ArgumentParser(prog="PyStalk", | ||
description="Tool to graph " | ||
"image metadata.") | ||
parser.add_argument('files', nargs='*', default=None, | ||
help='Path of photos to check.') | ||
parser.add_argument('-t', '--test', default=False, action="store_true", | ||
help='Does not show the graphs at the end.') | ||
# Logging function from https://stackoverflow.com/a/20663028 | ||
parser.add_argument('-d', '--debug', help="Sets logging level to DEBUG.", | ||
action="store_const", dest="loglevel", | ||
const=logging.DEBUG, default=logging.WARNING) | ||
parser.add_argument("-v", "--verbose", help="Sets logging level to INFO", | ||
action="store_const", dest="loglevel", | ||
const=logging.INFO) | ||
args = parser.parse_args() | ||
|
||
log = utils.make_logger("PyStalk", args.loglevel) | ||
log.info("Starting up") | ||
run(args, log) | ||
|
||
|
||
def run(args, log): | ||
"""Process files and generates graphs""" | ||
if not args.files: | ||
log.error("WARNING: No path was inputted. " | ||
"This will cause the script to break") | ||
sys.exit(1) | ||
|
||
for path in args.files: | ||
isdir = os.path.isdir(path) | ||
log.debug("Detected path as a directory") | ||
|
||
photos = [] | ||
invalid_photos = [] | ||
|
||
if isdir: | ||
for f in os.listdir(args.files[0]): | ||
with open(os.path.join(args.files[0], f), 'rb') as raw_photo: | ||
try: | ||
exif_image = Image(raw_photo) | ||
if exif_image.has_exif: | ||
photos.append(os.path.join(args.files[0], f)) | ||
else: | ||
invalid_photos.append(os.path.join(args.files[0], f)) | ||
except AssertionError: | ||
log.warning("Error with %s", raw_photo) | ||
else: | ||
for x, item in enumerate(args.files): | ||
with open(item, 'rb') as raw_photo: | ||
try: | ||
exif_image = Image(raw_photo) | ||
if exif_image.has_exif: | ||
photos.append(args.files[x]) | ||
log.debug("%s has exif data", item) | ||
else: | ||
invalid_photos.append(args.files[x]) | ||
except AssertionError: | ||
log.warning("Error with %s", raw_photo) | ||
|
||
plots = { | ||
"STATS": modules.Stats(photos, invalid_photos, log), | ||
"GPS": modules.GPS_Check(photos, log), | ||
"Timestamp": modules.date_time(photos, log), | ||
"Model": modules.PieChart(photos, "Model", log), | ||
"Flash": modules.PieChart(photos, "Flash", log), | ||
"Focal": modules.PieChart(photos, "Focal", log), | ||
"Software": modules.PieChart(photos, "Software", log) | ||
} | ||
|
||
utils.graph(plots, log, start, args.test) | ||
|
||
|
||
if __name__ == "__main__": | ||
setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters