Skip to content

Commit

Permalink
updated to use argparse instead of getopt, stable 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
torwart committed Jan 11, 2015
1 parent 4e606e4 commit f054ae1
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 50 deletions.
3 changes: 2 additions & 1 deletion .plugin_list
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'lib/git.py',
'lib/brew.py',
'lib/apt.py'
'lib/apt.py',
'lib/get.py'
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- cd tests
- python plugin_tests.py
- python plugin_tests2.py
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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!_

Expand All @@ -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``

Expand Down Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions bin/install-win32
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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.")
54 changes: 29 additions & 25 deletions bin/party
Original file line number Diff line number Diff line change
@@ -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():
Expand Down Expand Up @@ -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:])
print("no partyfile found.")
4 changes: 0 additions & 4 deletions docs/plugins/Write-a-Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
18 changes: 18 additions & 0 deletions docs/plugins/get-plugin.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit f054ae1

Please sign in to comment.