Commit 8c3d8a58 authored by Guillaume Seguin's avatar Guillaume Seguin

Merge branch 'experimental' of github.com:kliment/Printrun into experimental

parents bbec5e53 5d232a82
......@@ -28,8 +28,9 @@ A precompiled version is available at http://koti.kapsi.fi/~kliment/printrun/
You can run Printrun directly from source, as there are no packages available yet. Fetch and install the dependencies using
1. `sudo apt-get install python-serial python-wxgtk2.8 python-pyglet python-tornado python-setuptools python-libxml2 python-gobject avahi-daemon libavahi-compat-libdnssd1`
2. `sudo easy_install pybonjour tornado`
3. `sudo easy_install https://github.com/D1plo1d/py-mdns/archive/master.zip`
2. `sudo easy_install pybonjour`
3. `sudo easy_install https://github.com/nephics/tornado/archive/streambody.zip`
4. `sudo easy_install https://github.com/D1plo1d/py-mdns/archive/master.zip`
### Fedora 17 and newer
......@@ -45,9 +46,14 @@ Adding `--enablerepo updates-testing` option to `yum` might give you newer packa
You can also run Printrun directly from source, if the packages are too old for you anyway, or you have Fedora 15 or 16. Fetch and install the dependencies using
1. `sudo yum install pyserial wxpython pyglet python-tornado`
2. `sudo apt-get install avahi-daemon python-avahi tornado`
2. `sudo easy_install https://github.com/D1plo1d/py-mdns/archive/master.zip`
1. `sudo yum install pyserial wxpython pyglet`
To enable Prontserve you need to also install something along the following
lines. Unforunately this has yet to be tested on a real Fedora system:
1. `sudo yum install avahi avahi-python`
2. `sudo easy_install pybonjour`
3. `sudo easy_install https://github.com/nephics/tornado/archive/streambody.zip`
4. `sudo easy_install https://github.com/D1plo1d/py-mdns/archive/master.zip`
### Archlinux
......@@ -71,7 +77,7 @@ If you want to load stl files, you need to install a slicing program such as Sli
See the Slic3r readme for more details on integration.
# USING PRONSERVE
# USING PRONTSERVE
Prontserve runs a server for remotely monitoring and controlling your 3D printer over your network.
......
......@@ -204,18 +204,7 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
self.write_message(args)
def on_message(self, msg):
cmds_whitelist = [
"home",
"move",
"stop_move",
"set",
"estop",
"print",
"add_job",
"rm_job",
"change_job",
"get_jobs"
]
cmds = self._cmds()
print "message received: %s"%(msg)
msg = re.sub(r'\s+', "\s" ,msg).strip()
......@@ -237,9 +226,12 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
else:
args.append(w)
if cmd in cmds_whitelist:
if cmd in cmds.keys():
try:
self._throwArgErrors(cmd, args, kwargs)
# Set is already used by pronsole so we use construct_set
if cmd == "set": cmd = "construct_set"
# Run the command
response = getattr(prontserve, "do_%s"%cmd)(*args, **kwargs)
self.write_message({"ack": response})
except Exception as ex:
......@@ -248,6 +240,58 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
else:
self.write_message({"error": "%s command does not exist."%cmd})
def _cmds(self):
return {
"home": {
'array_args': True,
'args_error': "Home only (optionally) accepts axe names."
},
"move": {
'named_args': True,
'args_error': textwrap.dedent("""
Move only takes a list of axes, distance pairs and optionally @
prefixed feedrates.
""").strip()
},
"set": {
'namespaced': True, # namespaced by the machine aspect (temp)
'named_args': True,
'args_error': textwrap.dedent("""
Set only accepts a namespace and a list of heater, value pairs.
""").strip()
},
"estop": {
'args_error': "Estop does not accept any parameters."
},
"print": {
'args_error': "Print does not accept any parameters."
},
"rm_job": {
'namespaced': True, # namespaced by the job id
'args_error': "Rm_job only accepts a job_id."
},
"change_job": {
'namespaced': True, # namespaced by the job id
'named_args': True,
'args_error': textwrap.dedent("""
Change_job only accepts a job_id and a list of key/value pairs.
""").strip()
},
"get_jobs": {
'args_error': "Get_jobs does not accept any parameters."
}
}
def _throwArgErrors(self, cmd, args, kwargs):
meta = self._cmds()[cmd]
arg_errors = (len(kwargs) > 0 and not 'named_args' in meta)
arg_errors = arg_errors or (len(args) == 0 and 'namespaced' in meta)
minArgs = 0
if 'namespaced' in meta: minArgs = 1
arg_errors = arg_errors or (len(args) > minArgs and not 'array_args' in meta)
if arg_errors: raise Exception(meta['args_error'])
def on_close(self):
self.clients.remove(self)
prontserve.listeners.remove(self)
......@@ -372,7 +416,10 @@ class Prontserve(pronsole.pronsole, EventEmitter):
self.fire("estop")
def do_construct_set(self, subCmd, **kwargs):
getattr(self, "do_set_%s"%subCmd)(**kwargs)
method = "do_set_%s"%subCmd
if not hasattr(self, method):
raise Exception("%s is not a real namespace"%subCmd)
getattr(self, method)(**kwargs)
def do_set_temp(self, **kwargs):
# Setting each temperature individually
......@@ -399,7 +446,12 @@ class Prontserve(pronsole.pronsole, EventEmitter):
def do_change_job(self, job_id, **kwargs):
print job_id
print kwargs
self.jobs.update(int(job_id), kwargs)
try:
job_id = int(job_id)
except:
raise Exception("job_id must be a number")
self.jobs.update(job_id, kwargs)
def do_get_jobs(self):
jobexport = []
......@@ -569,7 +621,7 @@ class PrintJobQueue(EventEmitter):
def update(self, job_id, job_attrs):
job = self.find_by_id(job_id)
if job == None:
return False
raise Exception("There is no job #%i."%job_id)
# proposed future print quantity functionality
# if hasattr(job_attrs, 'qty'): job['qty'] = qty
if job_attrs['position']:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment