示例#1
0
def builder(something):
    def eta():
        progress = int(
            1000 * float(shit.p.queueindex) / len(shit.p.mainqueue)) / 10
        sys.stdout.write("Progress: %02.1f%%\r" % progress)
        sys.stdout.flush()

    shit = pronsole()
    shit.load_default_rc()
    shit.do_disconnect('')
    time.sleep(.2)
    shit.do_connect('')
    time.sleep(.2)
    shit.p.send_now('M106')  #always turn fan on
    shit.do_load(something)
    time.sleep(1)
    shit.do_print('')
    print "Printing Started"
    sys.stdout.write("Progress: 00.0%\r")
    sys.stdout.flush()

    while shit.p.printing:
        time.sleep(1)
        eta()
    print 'done printing'
    shit.do_exit('')
示例#2
0
def drop(leap):
    a = pronsole()
    a.preloop()
    a.load_default_rc()
    #	logger = logging.getLogger()
    #	logger .setLevel(logging.DEBUG)
    a.do_disconnect('')
    time.sleep(.2)
    a.do_connect('')
    time.sleep(3)
    a.p.loud = True
    a.p.send_now('G21')  #mm mode
    a.p.send_now('G90')  #absolute coordinates
    a.p.send_now('G28')  #home
    time.sleep(.25)
    a.p.send_now('G92 Z0')  #set z at top to be zero
    position = 'G1 Z' + str(leap)
    a.p.send_now(position)
    #a.p.send_now('') #add something wen sensor integration is done
    a.p.send_now('G92 z0')
    #print a.p.send_now('M114')
    time.sleep(2)
    stop = None
    #a.parse_cmdline(sys.argv[1:])
    setup_logging(sys.stdout, a.settings.log_path, True)
    loop(a)

    #	while (True):
    #
    #		print "in loop"
    #		time.sleep(1)
    #		sys.stdout.write("please wait\r")
    #             	time.sleep(1)
    #	#	a.p.send_now('M114')
    #		a.p._send('M114')
    #		#a.p._listen()
    #		#a.write_prompt()
    #	print  a.p.abs_pos
    print 'floor calibrations complete'
示例#3
0
    usage = "Usage:\n" + \
            "  pronsole [OPTION]\n\n" + \
            "Options:\n" + \
            "  -V, --version\t\t\tPrint program's version number and exit\n" + \
            "  -h, --help\t\t\tPrint this help message and exit\n"

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hV", ["help", "version"])
    except getopt.GetoptError, err:
        print str(err)
        print usage
        sys.exit(2)
    for o, a in opts:
        if o in ('-V', '--version'):
            print "printrun " + printcore_version
            sys.exit(0)
        elif o in ('-h', '--help'):
            print usage
            sys.exit(0)

    interp = pronsole()
    interp.parse_cmdline(sys.argv[1:])
    try:
        interp.cmdloop()
    except SystemExit:
        interp.p.disconnect()
    except:
        logging.error(
            _("Caught an exception, exiting:") + "\n" + traceback.format_exc())
        interp.p.disconnect()
import BaseHTTPServer
import time
from datetime import datetime
import socket
import json
import sys
import threading

from printerAdapter import *
from printrun.pronsole import pronsole

# Default IP and Port settings.
HOST_NAME = '127.0.0.1'
PORT_NUMBER = 1080

interp = pronsole()

""" Webserver classes. """

# @class: requestHandler
class requestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    # end createMTCHook
    # @function: do_HEAD
    def do_HEAD(s):
        # Send a success response.
        s.send_response(200)
        # Send the content type.
        s.send_header("Content-type", "text/xml")
        # End the headers.
        s.end_headers()
    # end do_HEAD
 def __init__(self):
         self.interp = pronsole()
         self.printing_on = 0
         self.adapter = myMTCAdapter("ultimaker", self.interp, self.printing_on)
示例#6
0
import subprocess
import sys
from django.http import HttpResponse
from django.conf import settings
from printrun.pronsole import pronsole

# PRONSOLE = subprocess.Popen(['python', settings.PRONSOLE_PATH],
#                          stdin=subprocess.PIPE)

PRONSOLE = pronsole()

def print_http_response(f):
    '''
        http://chase-seibert.github.io/blog/2010/08/06/redirect-console-output-to-a-django-httpresponse.html
        Wraps a python function that prints to the console, and 
        returns those results as a HttpResponse (HTML)
    '''
    
    class WritableObject:
        def __init__(self):
            self.content = []
        def write(self, string):
            self.content.append(string)     
    
    def new_f(*args, **kwargs):
        printed = WritableObject()
        sys.stdout = printed
        f(*args, **kwargs)
        sys.stdout = sys.__stdout__    
        return HttpResponse([c for c in printed.content ])         
    return new_f