Skip to content

updating watcher task functions to be cleaner, inspired by other PR #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# WatchMe Code of Conduct v1.0

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting @vsoch directly. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. @vsoch is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

## Thanks

This code of conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org/), version 1.4,
available at http://contributor-covenant.org/version/1/4.
87 changes: 7 additions & 80 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
This code is licensed under the MPL 2.0 [LICENSE](LICENSE).

# Contributing
When contributing to the SIF Python Client, it is important to properly communicate the
When contributing to the WatchMe Python Client, it is important to properly communicate the
gist of the contribution. If it is a simple code or editorial fix, simply
explaining this within the GitHub Pull Request (PR) will suffice. But if this
is a larger fix or Enhancement, it should be first discussed with the project
leader or developers.

Please note we have a code of conduct, described below. Please follow it in
all your interactions with the project members and users.
leader or developers. Please also note that we have a [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md)
that should be followed for all interactions with the project members and users.

## Pull Request Process

Expand All @@ -33,78 +31,7 @@ all your interactions with the project members and users.
done by the project lead, @vsoch (or approved by her).


# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project leader (@vsoch). All
complaints will be reviewed and investigated and will result in a response
that is deemed necessary and appropriate to the circumstances. The project
team is obligated to maintain confidentiality with regard to the reporter of
an incident. Further details of specific enforcement policies may be posted
separately.

Project maintainers, contributors and users who do not follow or enforce the
Code of Conduct in good faith may face temporary or permanent repercussions
with their involvement in the project as determined by the project's leader(s).

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
When you contribute to the project, you agree to add code under the provided
licensing terms, and also we ask that you add your name to the [AUTHORS](AUTHORS.md)
file. Any contribution in the way of documentation, features, or bug fixes is
greatly appreciated.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ watchme.egg-info/
dist
build
_site
.eggs
__pycache__
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ recursive-include watchme *
recursive-exclude * __pycache__
recursive-exclude * *.pyc
recursive-exclude * *.pyo
recursive-exclude .docs
recursive-exclude docs
recursive-exclude .docs *
recursive-exclude docs *
7 changes: 3 additions & 4 deletions docs/_docs/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ The configuration commands will vary based on the kind of task you want to add,
and here is a quick example of adding a task to watch a url (the default task):

```bash
$ watchme add watcher task-singularity-release url@https://github.com/sylabs/singularity/releases
$ watchme add-task watcher task-singularity-release url@https://github.com/sylabs/singularity/releases
[task-singularity-release]
url = https://github.com/sylabs/singularity/releases
active = true
Expand Down Expand Up @@ -207,7 +207,7 @@ The task is active by default (after you set up its schedule) and you can disabl
this with --active false:

```bash
$ watchme add watcher task-singularity-release url@https://github.com/sylabs/singularity/releases --active false
$ watchme add-task watcher task-singularity-release url@https://github.com/sylabs/singularity/releases --active false
```

The reason we save these parameters in the repo is that if you put it under version
Expand Down Expand Up @@ -639,5 +639,4 @@ $ watchme export system task-cpu vanessa-thinkpad-t460s_vanessa.json --json

## Licenses

This code is licensed under the Affero GPL, version 3.0 or later [LICENSE](LICENSE).
The SIF Header format is licesed by [Sylabs](https://github.com/sylabs/sif/blob/master/pkg/sif/sif.go).
This code is licensed under the Mozilla, version 2.0 or later [LICENSE](LICENSE).
26 changes: 25 additions & 1 deletion docs/_docs/install/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ order: 1

The only dependency for watchme is to have [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
and [crontab](https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-on-a-vps) on your system. Git is used for version control of the pages you are watching, and crontab is
used for scheduling your watches.
used for scheduling your watches. If you want to install a custom watcher type,
see [installing extras](#installing-extras) below.

## Install

Expand Down Expand Up @@ -62,3 +63,26 @@ actions:


If you have any questions or issues, please [open an issue]({{ site.repo }}/issues).

## Installing Extras

If you want to install all of watchme's exporters and watchers:

```bash
$ pip install watchme[all]
```

To install all watchers only:

```bash
$ pip install watchme[watchers]
```

or a specific watcher task group:

```bash
$ pip install watchme[watcher-urls-dynamic]
$ pip install watchme[watcher-psutils]
```

To see all of the choices, see [here](https://github.com/vsoch/watchme/blob/master/setup.py#L109) in the setup file.
2 changes: 1 addition & 1 deletion docs/_docs/watcher-tasks/psutils.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ basic python environment. If your python installation doesn't have the `psutil`
module, install as follows:

```bash
pip install watchme[psutils]
pip install watchme[watcher-psutils]
```

Next, create a watcher for your tasks to live under:
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/watcher-tasks/urls.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ identified by a class or id) on a page. For this purpose, you can use the functi
packages to do this:

```bash
$ pip install watchme[urls-dynamic]
$ pip install watchme[watcher-urls-dynamic]
```

This task will watch for changes based on a selection from a page. For example,
Expand Down
37 changes: 22 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@


from setuptools import setup, find_packages
import codecs
import os

################################################################################
# HELPER FUNCTIONS #############################################################
################################################################################


def get_lookup():
'''get version by way of singularity.version, returns a
'''get version by way of singularity.version, returns a
lookup dictionary with several global variables without
needing to import singularity
'''
Expand All @@ -28,32 +28,33 @@ def get_lookup():
exec(filey.read(), lookup)
return lookup


# Read in requirements
def get_requirements(lookup=None, key="INSTALL_REQUIRES"):
'''get_requirements reads in requirements and versions from
the lookup obtained with get_lookup'''

if lookup == None:
if lookup is None:
lookup = get_lookup()

install_requires = []
for module in lookup[key]:
module_name = module[0]
module_meta = module[1]
if "exact_version" in module_meta:
dependency = "%s==%s" %(module_name,module_meta['exact_version'])
dependency = "%s==%s" % (module_name, module_meta['exact_version'])
elif "min_version" in module_meta:
if module_meta['min_version'] == None:
min_version = module_meta['min_version']
if min_version is None:
dependency = module_name
else:
dependency = "%s>=%s" %(module_name,module_meta['min_version'])
dependency = "%s>=%s" % (module_name, min_version)
install_requires.append(dependency)
return install_requires



# Make sure everything is relative to setup.py
install_path = os.path.dirname(os.path.abspath(__file__))
install_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(install_path)

# Get version information from the lookup
Expand All @@ -76,8 +77,13 @@ def get_requirements(lookup=None, key="INSTALL_REQUIRES"):

if __name__ == "__main__":

# Install all exporters and/or watchers
INSTALL_REQUIRES = get_requirements(lookup)
URLS_DYNAMIC = get_requirements(lookup,'INSTALL_URLS_DYNAMIC')
INSTALL_ALL = get_requirements(lookup, 'INSTALL_ALL')
WATCHERS = get_requirements(lookup, 'INSTALL_WATCHERS')

# Watchers
URLS_DYNAMIC = get_requirements(lookup, 'INSTALL_URLS_DYNAMIC')
PSUTILS = get_requirements(lookup, 'INSTALL_PSUTILS')

setup(name=NAME,
Expand All @@ -86,7 +92,7 @@ def get_requirements(lookup=None, key="INSTALL_REQUIRES"):
author_email=AUTHOR_EMAIL,
maintainer=AUTHOR,
maintainer_email=AUTHOR_EMAIL,
packages=find_packages(),
packages=find_packages(),
include_package_data=True,
zip_safe=False,
url=PACKAGE_URL,
Expand All @@ -96,11 +102,12 @@ def get_requirements(lookup=None, key="INSTALL_REQUIRES"):
keywords=KEYWORDS,
setup_requires=["pytest-runner"],
tests_require=["pytest"],
install_requires = INSTALL_REQUIRES,
install_requires=INSTALL_REQUIRES,
extras_require={
'all': [INSTALL_REQUIRES],
'urls-dynamic': [URLS_DYNAMIC],
'psutils': [PSUTILS]
'all': [INSTALL_ALL],
'watchers': [WATCHERS],
'watcher-urls-dynamic': [URLS_DYNAMIC],
'watcher-psutils': [PSUTILS]
},
classifiers=[
'Intended Audience :: Science/Research',
Expand All @@ -113,4 +120,4 @@ def get_requirements(lookup=None, key="INSTALL_REQUIRES"):
'Programming Language :: Python :: 3',
],

entry_points = {'console_scripts': [ 'watchme=watchme.client:main' ] })
entry_points={'console_scripts': ['watchme=watchme.client:main']})
8 changes: 6 additions & 2 deletions watchme/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_parser():

# add

add = subparsers.add_parser("add",
add = subparsers.add_parser("add-task",
help="add a task to a watcher.")

add.add_argument('watcher', nargs=1,
Expand Down Expand Up @@ -151,6 +151,10 @@ def get_parser():
ls = subparsers.add_parser("list",
help="list all watchers at a base")

ls.add_argument('--watchers', dest="watchers",
help="list watchers available",
default=False, action='store_true')

# protect and freeze

protect = subparsers.add_parser("protect",
Expand Down Expand Up @@ -305,7 +309,7 @@ def help(return_code=0):
sys.exit(0)

if args.command == "activate": from .activate import main
elif args.command == "add": from .add import main
elif args.command == "add-task": from .add import main
elif args.command == "edit": from .edit import main
elif args.command == "export": from .export import main
elif args.command == "create": from .create import main
Expand Down
Loading