Skip to content

Commit

Permalink
Config changes (remove interval, add key, rename type)
Browse files Browse the repository at this point in the history
  • Loading branch information
pR0Ps committed Feb 23, 2014
1 parent 5d9ebcc commit 7ce8585
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 39 deletions.
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,37 @@ The client is configured using YAML.
Example config:

```yaml
make_css:
type: "less"
input: "project/less"
output: "project/css"
interval: 1
extras:
targets: ["main.less", "styles.less"]
logging: off

compile_haml:
type: "haml"
input: "project/haml"
output: "project/html"
interval: 1

compile_c:
type: "gccmake"
input: "helloworld" # Has a makefile and a hello.c file
output: "helloworld/bin"
interval: 5
extras:
targets: ['hello.out']
key: "s0mek3yh3re"
tasks:
make_css:
compiler: "less"
input: "project/less"
output: "project/css"
extras:
targets: ["main.less", "styles.less"]
logging: off

compile_coffee:
compiler: "coffee"
input: "project/coffee"
output: "project/js"

compile_c:
compiler: "gccmake"
input: "helloworld" # Has a makefile and a hello.c file
output: "helloworld/bin"
extras:
targets: ['hello.out']
```
Things to keep in mind:
- Indentation is important. Use tabs or spaces to indent, but not both.
- The `key` is your unique identification key that can be found on your account page.
- `make_css`, `compile_haml`, and `compile_c` are the names of the watch jobs.
- `type` is the type of compilation to perform.
- The `input` parameter can be a file or a directory.
- The `output` parameter is _always_ treated as a folder.
If you only want to output a single file, use the parent directory instead of the filename.
- `interval` is how long to wait (in seconds) between checking the filesystem for changes.
- C programs must have a makefile in the project directory

Key/value pairs under the `extras` parameter are all optional and differ based on the type of compilation being done.
Expand Down
17 changes: 9 additions & 8 deletions client/config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
debug:
type: "less"
input: "client"
output: "sample_compiled_output_dir"
interval: 1
extras:
logging: on
targets: ["main.less", "style.less"]
key: "s0mek3yh3r3"
tasks:
debug:
compiler: "less"
input: "client"
output: "sample_compiled_output_dir"
extras:
logging: on
targets: ["main.less", "style.less"]
4 changes: 2 additions & 2 deletions client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def __init__(self, config):
with open(config, "r") as f:
config = yaml.load(f.read())

self.s = Service()
self.s = Service(config['key'])

self.watchers = []
for k, v in config.items():
for k, v in config['tasks'].items():
self.watchers.append(Watcher(k, v, self.s))

def start_watching(self):
Expand Down
11 changes: 7 additions & 4 deletions client/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ class Service(object):

URL = "http://localhost:5000/{0}"

def __init__(self):
"""In the future sign into the API"""

def __init__(self, key):
"""Sign into the API"""

self.key = key
self.queue = queue.Queue()
self.worker = threading.Thread(target=self.serve_forever)
self.worker.start()
Expand Down Expand Up @@ -60,7 +61,9 @@ def serve_forever(self):

try:
msg = "ERROR: Couldn't communicate properly with the server"
r = requests.post(self.URL.format(conf['type']), files={"data": stream}, data=conf['extras'])
data = conf['extras']
data['key'] = self.key
r = requests.post(self.URL.format(conf['compiler']), files={"data": stream}, data=data)
if r.ok:
msg = "ERROR: Failed to extract the response from the server"
msg = self.extract_response(r, conf['output'])
Expand Down
2 changes: 1 addition & 1 deletion client/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def serve_forever(self):
# Wait until the job is processed before continuing
self.lock.acquire()
self.lock.release()
time.sleep(self.conf['interval'])
time.sleep(2)

def unlock(self, msg):
print ("{0}: {1}".format(self.name_, msg))
Expand Down
4 changes: 3 additions & 1 deletion precomp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def route(self, rule, *args, **kwargs):
MONGO_URI=os.environ['MONGO_URI'],
GITHUB_CLIENT_ID=os.environ['GITHUB_CLIENT_ID'],
GITHUB_CLIENT_SECRET=os.environ['GITHUB_CLIENT_SECRET'],
DO_CLIENT_ID=os.environ['DO_CLIENT_ID'],
DO_API_KEY=os.environ['DO_API_KEY'],
)
except KeyError as e:
try:
Expand Down Expand Up @@ -89,7 +91,7 @@ def get_service(processor):
"""routes subdomains to the right service"""

if processor not in processors:
return Response ("Invalid processor '{0}'. Valid processors are: {1}".format(processor, ", ".join(processors)), status=400)
return Response ("Invalid compiler '{0}'. Valid compilers are: {1}".format(processor, ", ".join(processors)), status=400)

elif request.files is None:
return Response ("No files recieved, should be 1", status=400)
Expand Down

0 comments on commit 7ce8585

Please sign in to comment.