Skip to content

Commit

Permalink
Modified to allow Installation via PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
kevthehermit committed Aug 30, 2016
1 parent 14f8805 commit a05210e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 13 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include ducktoolkit/languages *.json
Empty file added ducktoolkit/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions common.py → ducktoolkit/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

encoder_command_keys = [
"DELAY",
"SPACE",
Expand Down Expand Up @@ -120,3 +122,11 @@
"STOP",
"POWER"
]

def list_languages():
languages = []
lang_dir = os.path.join(os.path.dirname(__file__), 'languages')
for filename in os.listdir(lang_dir):
if filename.endswith('.json'):
languages.append(filename)
return languages
3 changes: 2 additions & 1 deletion decoder.py → ducktoolkit/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@


def decode_script(duck_lang, ducky_bin):
language_dict = os.path.join('languages', '{0}.json'.format(duck_lang))
lang_dir = os.path.join(os.path.dirname(__file__), 'languages')
language_dict = os.path.join(lang_dir, '{0}.json'.format(duck_lang))
lang_file = json.load(open(language_dict))
ducky_hex = ducky_bin.encode('hex')
decoded_bin = ""
Expand Down
3 changes: 2 additions & 1 deletion encoder.py → ducktoolkit/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def parse_text(duck_text, lang_file):

def encode_script(duck_text, duck_lang):

language_dict = os.path.join('languages', '{0}.json'.format(duck_lang))
lang_dir = os.path.join(os.path.dirname(__file__), 'languages')
language_dict = os.path.join(lang_dir, '{0}.json'.format(duck_lang))
lang_file = json.load(open(language_dict))

try:
Expand Down
Empty file.
File renamed without changes.
File renamed without changes.
18 changes: 7 additions & 11 deletions ducktools.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
#!/usr/bin/env python
import os
import sys
from optparse import OptionParser

import encoder
import decoder
from ducktoolkit import encoder, decoder
from ducktoolkit.common import list_languages

__description__ = 'Ducky Tools'
__author__ = 'Kevin Breen, James Hall, https://ducktoolkit.com'
__version__ = '0.1'
__version__ = '0.2'
__date__ = '25/08/2016'


def list_languages():
languages = []
for filename in os.listdir('languages'):
languages.append(filename)
return languages


if __name__ == "__main__":
parser = OptionParser(usage='usage: %prog [options] inputfile outputfile\n' + __description__,
version='%prog ' + __version__)
Expand All @@ -41,12 +33,16 @@ def list_languages():

if not language:
print "[!] You need to specify a supported language"
parser.print_help()
sys.exit()

if "{0}.json".format(language) not in list_languages():
print "[!] Language {0} is not supported at this time.".format(language)
print "[+] Supported Languages"
for lang in list_languages():
print " [-] {0}".format(lang.split('.')[0])
parser.print_help()
sys.exit()


if options.encode:
Expand Down
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python
from setuptools import setup, find_packages

setup(
name='ducktoolkit',
version='0.2',
author='Kevin Breen, James Hall',
author_email='[email protected]',
description="USB Rubber Ducky Toolkit",
url='https://ducktoolkit.com',
license='GNU V3',
zip_safe=False,
packages=find_packages(),
include_package_data=True,
scripts=['ducktools.py'],
package_data={'': ['*.json', 'README.md, LICENSE']},
)

0 comments on commit a05210e

Please sign in to comment.