Skip to content

Commit

Permalink
Merge branch 'complexity_rewrite'
Browse files Browse the repository at this point in the history
Version 1.3.3

See merge request Cyb3r-Jak3/pystalk!10

Signed-off-by: Jacob <[email protected]>
  • Loading branch information
Cyb3r-Jak3 committed Jan 10, 2020
2 parents b947363 + d74ab1f commit 10e3861
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ plugins:
enabled: false
pep8:
enabled: true
fixme:
enabled: true
bandit:
enabled: true
5 changes: 5 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ gemnasium-python-dependency_scanning:
stage: test
before_script:
- pip install numpy
only:
refs:
- master
- schedules


Coverage:
Expand Down Expand Up @@ -57,6 +61,7 @@ Coverage:
paths:
- bandit.json


python-3.5:
extends: ".check"
image: python:3.5
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<!-- markdownlint-disable MD024 -->
# Changelog
<!-- markdownlint-disable MD024 -->

## [v1.3.3] - 2020-01-10

### Changed

- Split directory searching and individual file searching to their own functions.
- Dependency scanning only takes place for master branch and scheduled runs.

### Removed

- fixme plugin for codeclimate

## [v1.3.2] - 2019-12-21

Expand Down
67 changes: 39 additions & 28 deletions PyStalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,46 +34,23 @@ def setup():

log = utils.make_logger("PyStalk", args.loglevel)
log.info("Starting up")
if not args.files:
log.error("ERROR: No path was inputted.")
sys.exit(1)
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)
photos, invalid_photos = directory_search(args.files[0], log)
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)
photos, invalid_photos = file_search(args.files, log)

plots = {
"STATS": modules.Stats(photos, invalid_photos, log),
Expand All @@ -88,5 +65,39 @@ def run(args, log):
utils.graph(plots, log, start, args.test)


def directory_search(files: list, log):
""" Used to append all file in a directory """
valid, invalid = [], []
for item in os.listdir(files):
with open(os.path.join(files, item), 'rb') as raw_photo:
try:
exif_image = Image(raw_photo)
if exif_image.has_exif:
valid.append(os.path.join(files, item))
log.debug("%s has exif data", item)
else:
invalid.append(os.path.join(files, item))
except AssertionError:
log.warning("Error with %s", raw_photo)
return valid, invalid


def file_search(files: list, log):
""" Used to append files if the path is not a directory """
valid, invalid = [], []
for x, item in enumerate(files):
with open(item, 'rb') as raw_photo:
try:
exif_image = Image(raw_photo)
if exif_image.has_exif:
valid.append(files[x])
log.debug("%s has exif data", item)
else:
invalid.append(files[x])
except AssertionError:
log.warning("Error with %s", raw_photo)
return valid, invalid


if __name__ == "__main__":
setup()
7 changes: 6 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

## About

PyStalk is a tool that can be used to generate graphs from the meta data of JPG and Tiff images. It currently creates graphs for gps coordinates and a pie chart for mode information.
PyStalk is a tool that can be used to generate graphs from the meta data of JPG and Tiff images.
It currently creates graphs for:

- GPS coordinates (map)
- Flash, focal, mode, software information (Pie Chart)
- Timestamp information (Chart)

Examples photos from [ianare/exif-samples](https://github.com/ianare/exif-samples/tree/master/jpg/gps), [exiftool](https://owl.phy.queensu.ca/~phil/exiftool/sample_images.html), [drewmpales/metadata-extractor-images](https://github.com/drewnoakes/metadata-extractor-images).

Expand Down

0 comments on commit 10e3861

Please sign in to comment.