Skip to content

Commit ba0967f

Browse files
authored
Merge pull request #34 from vsoch/update/reorganize
updating watcher task functions to be cleaner, inspired by other PR
2 parents 14a5b78 + a250137 commit ba0967f

File tree

23 files changed

+315
-210
lines changed

23 files changed

+315
-210
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# WatchMe Code of Conduct v1.0
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
26+
* Trolling, insulting/derogatory comments, and personal or political attacks
27+
* Public or private harassment
28+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
29+
* Other conduct which could reasonably be considered inappropriate in a professional setting
30+
31+
## Our Responsibilities
32+
33+
Project maintainers are responsible for clarifying the standards of acceptable
34+
behavior and are expected to take appropriate and fair corrective action in
35+
response to any instances of unacceptable behavior.
36+
37+
Project maintainers have the right and responsibility to remove, edit, or
38+
reject comments, commits, code, wiki edits, issues, and other contributions
39+
that are not aligned to this Code of Conduct, or to ban temporarily or
40+
permanently any contributor for other behaviors that they deem inappropriate,
41+
threatening, offensive, or harmful.
42+
43+
## Scope
44+
45+
This Code of Conduct applies both within project spaces and in public spaces
46+
when an individual is representing the project or its community. Examples of
47+
representing a project or community include using an official project e-mail
48+
address, posting via an official social media account, or acting as an appointed
49+
representative at an online or offline event. Representation of a project may be
50+
further defined and clarified by project maintainers.
51+
52+
## Enforcement
53+
54+
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.
55+
56+
## Thanks
57+
58+
This code of conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org/), version 1.4,
59+
available at http://contributor-covenant.org/version/1/4.

.github/CONTRIBUTING.md

Lines changed: 7 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
This code is licensed under the MPL 2.0 [LICENSE](LICENSE).
33

44
# Contributing
5-
When contributing to the SIF Python Client, it is important to properly communicate the
5+
When contributing to the WatchMe Python Client, it is important to properly communicate the
66
gist of the contribution. If it is a simple code or editorial fix, simply
77
explaining this within the GitHub Pull Request (PR) will suffice. But if this
88
is a larger fix or Enhancement, it should be first discussed with the project
9-
leader or developers.
10-
11-
Please note we have a code of conduct, described below. Please follow it in
12-
all your interactions with the project members and users.
9+
leader or developers. Please also note that we have a [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md)
10+
that should be followed for all interactions with the project members and users.
1311

1412
## Pull Request Process
1513

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

3533

36-
# Code of Conduct
37-
38-
## Our Pledge
39-
40-
In the interest of fostering an open and welcoming environment, we as
41-
contributors and maintainers pledge to making participation in our project and
42-
our community a harassment-free experience for everyone, regardless of age, body
43-
size, disability, ethnicity, gender identity and expression, level of experience,
44-
nationality, personal appearance, race, religion, or sexual identity and
45-
orientation.
46-
47-
## Our Standards
48-
49-
Examples of behavior that contributes to creating a positive environment
50-
include:
51-
52-
* Using welcoming and inclusive language
53-
* Being respectful of differing viewpoints and experiences
54-
* Gracefully accepting constructive criticism
55-
* Focusing on what is best for the community
56-
* Showing empathy towards other community members
57-
58-
Examples of unacceptable behavior by participants include:
59-
60-
* The use of sexualized language or imagery and unwelcome sexual attention or
61-
advances
62-
* Trolling, insulting/derogatory comments, and personal or political attacks
63-
* Public or private harassment
64-
* Publishing others' private information, such as a physical or electronic
65-
address, without explicit permission
66-
* Other conduct which could reasonably be considered inappropriate in a
67-
professional setting
68-
69-
### Our Responsibilities
70-
71-
Project maintainers are responsible for clarifying the standards of acceptable
72-
behavior and are expected to take appropriate and fair corrective action in
73-
response to any instances of unacceptable behavior.
74-
75-
Project maintainers have the right and responsibility to remove, edit, or
76-
reject comments, commits, code, wiki edits, issues, and other contributions
77-
that are not aligned to this Code of Conduct, or to ban temporarily or
78-
permanently any contributor for other behaviors that they deem inappropriate,
79-
threatening, offensive, or harmful.
80-
81-
## Scope
82-
83-
This Code of Conduct applies both within project spaces and in public spaces
84-
when an individual is representing the project or its community. Examples of
85-
representing a project or community include using an official project e-mail
86-
address, posting via an official social media account, or acting as an appointed
87-
representative at an online or offline event. Representation of a project may be
88-
further defined and clarified by project maintainers.
89-
90-
## Enforcement
91-
92-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
93-
reported by contacting the project leader (@vsoch). All
94-
complaints will be reviewed and investigated and will result in a response
95-
that is deemed necessary and appropriate to the circumstances. The project
96-
team is obligated to maintain confidentiality with regard to the reporter of
97-
an incident. Further details of specific enforcement policies may be posted
98-
separately.
99-
100-
Project maintainers, contributors and users who do not follow or enforce the
101-
Code of Conduct in good faith may face temporary or permanent repercussions
102-
with their involvement in the project as determined by the project's leader(s).
103-
104-
## Attribution
105-
106-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
107-
available at [http://contributor-covenant.org/version/1/4][version]
108-
109-
[homepage]: http://contributor-covenant.org
110-
[version]: http://contributor-covenant.org/version/1/4/
34+
When you contribute to the project, you agree to add code under the provided
35+
licensing terms, and also we ask that you add your name to the [AUTHORS](AUTHORS.md)
36+
file. Any contribution in the way of documentation, features, or bug fixes is
37+
greatly appreciated.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ watchme.egg-info/
22
dist
33
build
44
_site
5+
.eggs
56
__pycache__

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ recursive-include watchme *
33
recursive-exclude * __pycache__
44
recursive-exclude * *.pyc
55
recursive-exclude * *.pyo
6-
recursive-exclude .docs
7-
recursive-exclude docs
6+
recursive-exclude .docs *
7+
recursive-exclude docs *

docs/_docs/getting-started/index.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ The configuration commands will vary based on the kind of task you want to add,
172172
and here is a quick example of adding a task to watch a url (the default task):
173173
174174
```bash
175-
$ watchme add watcher task-singularity-release url@https://github.com/sylabs/singularity/releases
175+
$ watchme add-task watcher task-singularity-release url@https://github.com/sylabs/singularity/releases
176176
[task-singularity-release]
177177
url = https://github.com/sylabs/singularity/releases
178178
active = true
@@ -207,7 +207,7 @@ The task is active by default (after you set up its schedule) and you can disabl
207207
this with --active false:
208208
209209
```bash
210-
$ watchme add watcher task-singularity-release url@https://github.com/sylabs/singularity/releases --active false
210+
$ watchme add-task watcher task-singularity-release url@https://github.com/sylabs/singularity/releases --active false
211211
```
212212
213213
The reason we save these parameters in the repo is that if you put it under version
@@ -639,5 +639,4 @@ $ watchme export system task-cpu vanessa-thinkpad-t460s_vanessa.json --json
639639
640640
## Licenses
641641
642-
This code is licensed under the Affero GPL, version 3.0 or later [LICENSE](LICENSE).
643-
The SIF Header format is licesed by [Sylabs](https://github.com/sylabs/sif/blob/master/pkg/sif/sif.go).
642+
This code is licensed under the Mozilla, version 2.0 or later [LICENSE](LICENSE).

docs/_docs/install/index.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ order: 1
1010

1111
The only dependency for watchme is to have [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
1212
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
13-
used for scheduling your watches.
13+
used for scheduling your watches. If you want to install a custom watcher type,
14+
see [installing extras](#installing-extras) below.
1415

1516
## Install
1617

@@ -62,3 +63,26 @@ actions:
6263

6364

6465
If you have any questions or issues, please [open an issue]({{ site.repo }}/issues).
66+
67+
## Installing Extras
68+
69+
If you want to install all of watchme's exporters and watchers:
70+
71+
```bash
72+
$ pip install watchme[all]
73+
```
74+
75+
To install all watchers only:
76+
77+
```bash
78+
$ pip install watchme[watchers]
79+
```
80+
81+
or a specific watcher task group:
82+
83+
```bash
84+
$ pip install watchme[watcher-urls-dynamic]
85+
$ pip install watchme[watcher-psutils]
86+
```
87+
88+
To see all of the choices, see [here](https://github.com/vsoch/watchme/blob/master/setup.py#L109) in the setup file.

docs/_docs/watcher-tasks/psutils.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ basic python environment. If your python installation doesn't have the `psutil`
1111
module, install as follows:
1212

1313
```bash
14-
pip install watchme[psutils]
14+
pip install watchme[watcher-psutils]
1515
```
1616

1717
Next, create a watcher for your tasks to live under:

docs/_docs/watcher-tasks/urls.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ identified by a class or id) on a page. For this purpose, you can use the functi
194194
packages to do this:
195195

196196
```bash
197-
$ pip install watchme[urls-dynamic]
197+
$ pip install watchme[watcher-urls-dynamic]
198198
```
199199

200200
This task will watch for changes based on a selection from a page. For example,

setup.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111

1212
from setuptools import setup, find_packages
13-
import codecs
1413
import os
1514

1615
################################################################################
1716
# HELPER FUNCTIONS #############################################################
1817
################################################################################
1918

19+
2020
def get_lookup():
21-
'''get version by way of singularity.version, returns a
21+
'''get version by way of singularity.version, returns a
2222
lookup dictionary with several global variables without
2323
needing to import singularity
2424
'''
@@ -28,32 +28,33 @@ def get_lookup():
2828
exec(filey.read(), lookup)
2929
return lookup
3030

31+
3132
# Read in requirements
3233
def get_requirements(lookup=None, key="INSTALL_REQUIRES"):
3334
'''get_requirements reads in requirements and versions from
3435
the lookup obtained with get_lookup'''
3536

36-
if lookup == None:
37+
if lookup is None:
3738
lookup = get_lookup()
3839

3940
install_requires = []
4041
for module in lookup[key]:
4142
module_name = module[0]
4243
module_meta = module[1]
4344
if "exact_version" in module_meta:
44-
dependency = "%s==%s" %(module_name,module_meta['exact_version'])
45+
dependency = "%s==%s" % (module_name, module_meta['exact_version'])
4546
elif "min_version" in module_meta:
46-
if module_meta['min_version'] == None:
47+
min_version = module_meta['min_version']
48+
if min_version is None:
4749
dependency = module_name
4850
else:
49-
dependency = "%s>=%s" %(module_name,module_meta['min_version'])
51+
dependency = "%s>=%s" % (module_name, min_version)
5052
install_requires.append(dependency)
5153
return install_requires
5254

5355

54-
5556
# Make sure everything is relative to setup.py
56-
install_path = os.path.dirname(os.path.abspath(__file__))
57+
install_path = os.path.dirname(os.path.abspath(__file__))
5758
os.chdir(install_path)
5859

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

7778
if __name__ == "__main__":
7879

80+
# Install all exporters and/or watchers
7981
INSTALL_REQUIRES = get_requirements(lookup)
80-
URLS_DYNAMIC = get_requirements(lookup,'INSTALL_URLS_DYNAMIC')
82+
INSTALL_ALL = get_requirements(lookup, 'INSTALL_ALL')
83+
WATCHERS = get_requirements(lookup, 'INSTALL_WATCHERS')
84+
85+
# Watchers
86+
URLS_DYNAMIC = get_requirements(lookup, 'INSTALL_URLS_DYNAMIC')
8187
PSUTILS = get_requirements(lookup, 'INSTALL_PSUTILS')
8288

8389
setup(name=NAME,
@@ -86,7 +92,7 @@ def get_requirements(lookup=None, key="INSTALL_REQUIRES"):
8692
author_email=AUTHOR_EMAIL,
8793
maintainer=AUTHOR,
8894
maintainer_email=AUTHOR_EMAIL,
89-
packages=find_packages(),
95+
packages=find_packages(),
9096
include_package_data=True,
9197
zip_safe=False,
9298
url=PACKAGE_URL,
@@ -96,11 +102,12 @@ def get_requirements(lookup=None, key="INSTALL_REQUIRES"):
96102
keywords=KEYWORDS,
97103
setup_requires=["pytest-runner"],
98104
tests_require=["pytest"],
99-
install_requires = INSTALL_REQUIRES,
105+
install_requires=INSTALL_REQUIRES,
100106
extras_require={
101-
'all': [INSTALL_REQUIRES],
102-
'urls-dynamic': [URLS_DYNAMIC],
103-
'psutils': [PSUTILS]
107+
'all': [INSTALL_ALL],
108+
'watchers': [WATCHERS],
109+
'watcher-urls-dynamic': [URLS_DYNAMIC],
110+
'watcher-psutils': [PSUTILS]
104111
},
105112
classifiers=[
106113
'Intended Audience :: Science/Research',
@@ -113,4 +120,4 @@ def get_requirements(lookup=None, key="INSTALL_REQUIRES"):
113120
'Programming Language :: Python :: 3',
114121
],
115122

116-
entry_points = {'console_scripts': [ 'watchme=watchme.client:main' ] })
123+
entry_points={'console_scripts': ['watchme=watchme.client:main']})

watchme/client/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def get_parser():
112112

113113
# add
114114

115-
add = subparsers.add_parser("add",
115+
add = subparsers.add_parser("add-task",
116116
help="add a task to a watcher.")
117117

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

154+
ls.add_argument('--watchers', dest="watchers",
155+
help="list watchers available",
156+
default=False, action='store_true')
157+
154158
# protect and freeze
155159

156160
protect = subparsers.add_parser("protect",
@@ -305,7 +309,7 @@ def help(return_code=0):
305309
sys.exit(0)
306310

307311
if args.command == "activate": from .activate import main
308-
elif args.command == "add": from .add import main
312+
elif args.command == "add-task": from .add import main
309313
elif args.command == "edit": from .edit import main
310314
elif args.command == "export": from .export import main
311315
elif args.command == "create": from .create import main

0 commit comments

Comments
 (0)