From f054ae165125329ce7b2aebfaad8415d0d6b51f8 Mon Sep 17 00:00:00 2001 From: torwart Date: Sun, 11 Jan 2015 20:06:52 +0100 Subject: [PATCH] updated to use argparse instead of getopt, stable 0.1 --- .plugin_list | 3 +- .travis.yml | 10 +++---- README.md | 24 ++++++++------- bin/install-win32 | 7 +++-- bin/party | 54 ++++++++++++++++++---------------- docs/plugins/Write-a-Plugin.md | 4 --- docs/plugins/get-plugin.md | 18 ++++++++++++ 7 files changed, 70 insertions(+), 50 deletions(-) create mode 100644 docs/plugins/get-plugin.md diff --git a/.plugin_list b/.plugin_list index 4e77814..470baee 100644 --- a/.plugin_list +++ b/.plugin_list @@ -1,3 +1,4 @@ 'lib/git.py', 'lib/brew.py', -'lib/apt.py' \ No newline at end of file +'lib/apt.py', +'lib/get.py' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index a8b5608..703334b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,9 @@ language: python python: 3.4.2 install: - - sudo apt-get install python3.4 python3.4-dev git - - cd bin - - python install + - sudo apt-get install python3.4 python3.4-dev git script: - - cd tests - - python plugin_tests.py - - python plugin_tests2.py \ No newline at end of file + - cd tests + - python plugin_tests.py + - python plugin_tests2.py \ No newline at end of file diff --git a/README.md b/README.md index 786ff7a..eb26eb5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > The python task runner -``party`` is an task runner written in python for python. It automates all the steps which the users need to do, like installing components, updating dependencies or getting the latest source. Also its very extensible and you can [create](https://github.com/torwart/party/blob/master/docs/plugins/Write-a-Plugin.md) and [install](https://torwart.github.io/party-registry) plugins. You can view the [documentation](https://github.com/torwart/party/blob/master/docs) for more informations. +``party`` is an task runner written in python for python. It automates all the steps which the users need to do, like installing components, updating dependencies or getting the latest source. Also its very extensible and you can [create](https://github.com/torwart/party/blob/master/docs/plugins/Write-a-Plugin.md) and install plugins. You can view the [documentation](https://github.com/torwart/party/blob/master/docs) for more informations. ![preview image](http://i.imgur.com/6p5zsqV.png) @@ -17,13 +17,15 @@ first (_installer script on Windows supports only Python 3.4.x_). #### Windows -Start the command prompt (or use Git Bash) and run the following: +Download one of the [latest releases](https://github.com/torwart/party/releases), and extract the ZIP/TAR package. +Fire up an command prompt and run this: - $ git clone https://github.com/torwart/party.git - $ cd party/bin - $ python install-win32 +```sh +$ cd bin +$ python install-win32 +``` -If you receive an ``INSTALLED SUCCESSFULLY AND COPIED PLUGINS!``, you can be 100% sure that ``party`` is installed correctly. **But dont't forget to add the ``bin`` directory to your PATH!** +if you receive 'everything fine.', you can be sure that ``party`` is installed. **You'll need to add the bin directory to your PATH manually!** _If you use an older version of Python you can follow the steps for Linux/OSX to manual install party!_ @@ -38,14 +40,13 @@ _Currently I am not able to run an Linux or OSX system and this is a manual way 5. Add the ``bin`` directory to your **PATH** 6. _not required:_ on some systems you'll need to reboot -Now you can test if ``party`` was successfully installed. This can be done using the ``Python command line``, fire it up and run this: +Now you can test if ``party`` was successfully installed. This can be done by running this in terminal: -```py ->>> from party_plugins import git ->>> client = git.gitClient() +```sh +$ party -v ``` -If this return no errors, you can be sure that you've installed ``party`` on your system. +If this shows you the version informations, everything works fine. ## Sample ``partyfile.py`` @@ -77,6 +78,7 @@ These plugins are shipped with ``party``: - [.git](https://github.com/torwart/party/blob/master/plugins/git.py): an easy to use git client for your partyfiles - [.brew](https://github.com/torwart/party/blob/master/plugins/brew.py): an easy to use homebrew client for your partyfiles (**OSX only**) - [.apt](https://github.com/torwart/party/blob/master/plugins/apt.py): an easy to use apt-get client for your partyfiles (**UNIX only**) +- [.get](https://github.com/torwart/party/blob/master/plugins/git.py): an easy to use download client for your partyfiles ## Known Issues diff --git a/bin/install-win32 b/bin/install-win32 index eefdee8..aea876a 100644 --- a/bin/install-win32 +++ b/bin/install-win32 @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2014 Jan Kowalewicz and contributors. All rights reserved. +# Copyright 2014-2015 Jan Kowalewicz and contributors. All rights reserved. # The source code is governed by an MIT X11-License which can be found # in the root directory. @@ -15,13 +15,14 @@ def CopyPlugins(): shutil.copy2('../plugins/git.py', 'c://python34/lib/site-packages/party_plugins') shutil.copy2('../plugins/brew.py', 'c://python34/lib/site-packages/party_plugins') shutil.copy2('../plugins/apt.py', 'c://python34/lib/site-packages/party_plugins') + shutil.copy2('../plugins/get.py', 'c://python34/lib/site-packages/party_plugins') # todo.. if __name__ == '__main__': try: CreateSitePackagesFolder() CopyPlugins() - print("inf: INSTALLED SUCCESSFULLY AND COPIED PLUGINS!") - print("DON'T FORGET TO ADD THE BIN DIRECTORY TO YOUR PATH! OTHERWISE PARTY WILL NOT WORK.") + print("everything fine.") + print("don't forget to add the bin directory to your path.") except: print("err: INSTALLATION ABORTED BY ABOVE ERROR.") \ No newline at end of file diff --git a/bin/party b/bin/party index 28bcfc5..5eeafb8 100644 --- a/bin/party +++ b/bin/party @@ -1,14 +1,14 @@ #!/usr/bin/env python -# Copyright 2014 Jan Kowalewicz and contributors. All rights reserved. +# Copyright 2014-2015 Jan Kowalewicz and contributors. All rights reserved. # The source code is governed by an MIT X11-License which can be found # in the root directory. import os import sys -import getopt import shutil import fileinput +import argparse class _partyfile(): def _init(): @@ -42,30 +42,34 @@ def runTasks(): os.system('python _party_out.py') os.remove('_party_out.py') -class cliopts(): - def mrun(argv): - try: - opts, args = getopt.getopt(argv, "iuh:v", ["init", "update", "vhelp"]) - except getopt.GetoptError: - print("invalid command.") - sys.exit(2) - for opt, arg in opts: - if opt in ("-i", "--init"): - try: - _partyfile._init() - except: - print("error creating partyfile in this directory.") - finally: - print("created partyfile.") - elif opt == '-v': - print("party0.1\nyou can update by running '--update'") - elif opt in ("-u", "--update"): - print("---") +def cli(): + p = argparse.ArgumentParser(description='Python task runner') + + p.add_argument('-r', help='runs an partyfile', action='store_true') + p.add_argument('-v', help='shows version informations', action='store_true') + p.add_argument('-u', help='searches for newer versions of party', action='store_true') + p.add_argument('-i', help='creates an new partyfile in the current directory', action='store_true') + + a = p.parse_args() + + if a.r: + _partyfile._translate() + + elif a.v: + print("party version 0.1\nyou can update by running -u") + + elif a.u: + print("this is work in progress.") + + elif a.i: + _partyfile._init() + + else: + print("you'll need to add an option.") if __name__ == '__main__': try: - _partyfile._translate(); + cli() + except: - # currently this will be deactivated if an partyfile - # exists. - cliopts.mrun(sys.argv[1:]) \ No newline at end of file + print("no partyfile found.") \ No newline at end of file diff --git a/docs/plugins/Write-a-Plugin.md b/docs/plugins/Write-a-Plugin.md index 2301b53..c9b6129 100644 --- a/docs/plugins/Write-a-Plugin.md +++ b/docs/plugins/Write-a-Plugin.md @@ -19,10 +19,6 @@ Fire up Sublime text editor (or whatever text editor you use) and paste this (co import os import sys -import party -# or use -sys.path.insert(0, '/path/to/party/installation') -# and then use 'import party' # create a new class yourClassName will be represent in the partyfile like gitClient or brewClient class yourClassName(): diff --git a/docs/plugins/get-plugin.md b/docs/plugins/get-plugin.md new file mode 100644 index 0000000..4fb9ea1 --- /dev/null +++ b/docs/plugins/get-plugin.md @@ -0,0 +1,18 @@ +# get.py + +**class**: ``downloadClient`` + +**functions**: ``curl``, ``wget`` + +## Example Usage + +```py +#!=party + +from party_plugins import apt + +task def install_packages(): + client = get.downloadClient() # create new client + + client.wget('https://example.com/example.zip') # gets an ZIP from URL +```