Beispiel #1
0
 def run(self):
     print("server starting...")
     print("listening on %s:%i" % (self.__host,self.__port))
     #to provide https support? not sure if this is correct, doesn't seem to work,
     #    need proxy also...
     #run(self.__create_publisher,host=self.__host,port=self.__port,https=True)
     run(self.__create_publisher,host=self.__host,port=self.__port)
def main():
    parser = get_server_parser(DESCRIPTION)
    parser.set_usage(USAGE)
    parser.remove_option('--factory')
    opts, args = parser.parse_args()
    if len(args) != 1:
        parser.error("wrong number of command-line args")
    factory_name = "use_" + args[0]
    try:
        factory = globals()[factory_name]
    except KeyError:
        parser.error("unknown storage type")
    simple_server.run(factory, opts.host, opts.port)
Beispiel #3
0
from quixote.publish import Publisher
from quixote.directory import Directory


def create_publisher():
    "Create & return a test publisher entry"
    p = Publisher(TestServer())
    p.is_thread_safe = True

    return p


class TestServer(Directory):
    _q_exports = ['', 'exit']

    def _q_index(self):
        return "hello, world"

    def exit(self):
        raise SystemExit


if __name__ == '__main__':
    from quixote.server.simple_server import run
    port = int(os.environ.get('QX_TEST_PORT', '8080'))
    print 'starting qx_testserver on port %d.' % (port, )
    try:
        run(create_publisher, port=port)
    except KeyboardInterrupt:
        pass
	    numbers = retrieve_text("%s/%s" %(_tesseract_temp_path,newegg.hexdigest()) );
	    os.remove("%s/%s.%s" %(_tesseract_temp_path,newegg.hexdigest(),_suning_filename_flag))
	    os.remove("%s/%s-convert.tiff" %(_tesseract_temp_path,newegg.hexdigest()))
	    os.remove("%s/%s.txt" %(_tesseract_temp_path,newegg.hexdigest()))
	    return numbers
	    if numbers == None:
		return '0'
	    else:
		return numbers
	except IOError:
	    return '0'        

def retrieve_text(scratch_text_name_root):
    if _add_dot_txt_flag:
	inf = file(scratch_text_name_root + '.txt')
    else:
	inf = file(scratch_text_name_root)
    text = inf.read().strip()
    inf.close()
    return text

def create_publisher():
    return Publisher(RootDirectory(),
                     display_exceptions='plain')


if __name__ == '__main__':
    from quixote.server.simple_server import run
    print 'creating website listening on http://192.168.1.48:8099/'
    run(create_publisher, host='192.168.1.48', port=8099)
Beispiel #5
0
    """
    An XML-RPC "dating" function that connects specific functions ('fn')
    and parameters to call the actual function requested.  Could use a
    dict or an object lookup or whatever you wanted here.
    """
    
    if fn == 'hello':
        return hello_fn(*params)
    elif fn == 'random':
        return random_fn(*params)
    
class RootDirectory(Directory):

    _q_exports = ['', 'xmlrpc']

    def _q_index(self):
        return '''These are not the droids you are looking for.'''

    def xmlrpc(self):
        request = quixote.get_request()
        return xmlrpc(request, process_xmlrpc)

def create_publisher():
    return Publisher(RootDirectory(), display_exceptions='plain')


if __name__ == '__main__':
    from quixote.server.simple_server import run
    print 'creating xmlrpc server listening on http://localhost:8080/'
    run(create_publisher, host='localhost', port=8080)
		for l in self.liste.keys():
			S=S+l+'	'+str(self.liste[l])+'\n'
		for l in self.lines.keys():
			S=S+l+'\n'
		return S
	
	def interface(self):
		myVariable=templatesdir
		template = env.get_template('kMerBrowserInterface.html')
		return template.render(locals())
		
def create_publisher():
	publisher = Publisher(myFirstUI(),display_exceptions='plain',)
	return publisher

if __name__ == '__main__':
	thisdir = os.path.dirname(__file__)
	templatesdir = os.path.join(thisdir, 'data')
	templatesdir = os.path.abspath(templatesdir)
	loader = jinja2.FileSystemLoader(templatesdir)
	env = jinja2.Environment(loader=loader)
		
	from quixote.server.simple_server import run
	
	# please choose your publisher here:
	#keep in mind that this publisher has to match the kmerBrowserInterface URL!
	
	print 'creating demo listening on http://vertex.beacon.msu.edu:8080/'
	#run(create_publisher, host='localhost', port=8080)
	run(create_publisher, host='vertex.beacon.msu.edu', port=8080)
Beispiel #7
0
 def _run(self):
     while True: 
         print 'creating website listening on http://192.168.1.48:8099/'
         run(create_publisher, host='192.168.1.48', port=8099)
         time.sleep(1)
Beispiel #8
0
from quixote.server import simple_server
from quixote.publish import Publisher
from quixote.directory import Directory

class MySite(Directory):
    _q_exports = ["hello"]
    def hello(self):
        return "hello"


def factory():
    return Publisher(MySite())

if __name__ == "__main__":
    simple_server.run(factory, "localhost", 7080)
Beispiel #9
0
    def _q_access(self):
        r = get_request()

        print '======================== NEW REQUEST'
        for k, v in r.environ.items():
            print '***', k, ':', v

        ha = r.get_environ('HTTP_AUTHORIZATION', None)
        if ha:
            auth_type, auth_string = ha.split()
            login, passwd = base64.decodestring(auth_string).split(':')
 
            if login == 'test' and passwd == 'password':
                return
            
        raise UnauthorizedError

    def _q_index(self):
        return "you made it!"

####

if __name__ == '__main__':
    from quixote.server.simple_server import run
    port = int(os.environ.get('TWILL_TEST_PORT', '8080'))
    print 'starting twilltestserver on port %d.' % (port,)
    try:
        run(create_publisher, port=port)
    except KeyboardInterrupt:
        pass
Beispiel #10
0
def selector(songs):
    global player, song
    chosen = get_field("select")
    if chosen:
        song = chosen
        player = play(song)
        redirect("stopper") # works with Mozilla, but not with lynx/elinks
    else:
        f = Form()
        f.add_single_select("select", options=songs)
        f.add_submit("play", "Play!")
        return f.render()

def stopper():
    stop = get_field("stop")
    if stop:
        player.kill()
        return simplepage(body = "%s stopped." % song)
    else:
        f = Form()
        f.add_submit("stop", "Stop")
        return simplepage(body= ("Playing %s" % song) +
                          f.render())

top.stopper = lambda : stopper()

if __name__ == '__main__':
    print 'Listening on http://localhost:8080 ...'
    run(lambda : Publisher(top), '', 8080)
Beispiel #11
0
#! /usr/bin/env python
import quixote.demo
from quixote.server.simple_server import run

run(quixote.demo.create_publisher, host='', port=8080)
            os.remove("%s/%s-convert.tiff" %
                      (_tesseract_temp_path, newegg.hexdigest()))
            os.remove("%s/%s.txt" % (_tesseract_temp_path, newegg.hexdigest()))
            return numbers
            if numbers == None:
                return '0'
            else:
                return numbers
        except IOError:
            return '0'


def retrieve_text(scratch_text_name_root):
    if _add_dot_txt_flag:
        inf = file(scratch_text_name_root + '.txt')
    else:
        inf = file(scratch_text_name_root)
    text = inf.read().strip()
    inf.close()
    return text


def create_publisher():
    return Publisher(RootDirectory(), display_exceptions='plain')


if __name__ == '__main__':
    from quixote.server.simple_server import run
    print 'creating website listening on http://192.168.1.48:8099/'
    run(create_publisher, host='192.168.1.48', port=8099)
Beispiel #13
0
 def run(self):
     print("server starting...\nlistening on %s:%i" % (self.__host,self.__port))
     run(self.__create_publisher,host=self.__host,port=self.__port)
Beispiel #14
0
class RootDirectory(Directory):

    _q_exports = ['', 'hello']

    def _q_index(self):
        return '''<html>
                    <body>Welcome to the Quixote demo.  Here is a
                    <a href="hello">link</a>.
                    </body>
                  </html>
                '''

    def hello(self):
        global last_time
        now = time.time()
        print 'took %.4f' % (now - last_time)
        last_time = time.time()
        return '<html><body>Hello world!</body></html>'


def create_publisher():
    return Publisher(RootDirectory(),
                     display_exceptions='plain')


if __name__ == '__main__':
    from quixote.server.simple_server import run
    print 'creating demo listening on http://localhost:8081/'
    run(create_publisher, host='0', port=8081)
Beispiel #15
0
def main():
    # create an http server bound to the host and port specified
    # and publish the Root instance.
    run(create_publisher, host="127.0.0.1", port=8080)
Beispiel #16
0
		
	def B(self):
		mfsfc=myFirstServices.firstClass;
		return '''<html><p>B</p></html>'''
		
def session_manager():
	from session2.store.VolatileSessionStore import VolatileSessionStore
	store = VolatileSessionStore()
	#DirectorySessionStore(config.sessions_dir, create=True)
	from session2.SessionManager import SessionManager
	session_manager = SessionManager(store)
	return SessionManager(store, Session)

def create_publisher():
	#publisher=Publisher(myFirstUI(),display_exceptions='plain')
	#publisher=Publisher(myFirstUI(),session_manager)
	#quixote.DEFAULT_CHARSET = config.output_encoding
	publisher = Publisher(myFirstUI(),display_exceptions='plain',session_cookie_name="VORTEX_Session",session_manager=session_manager(),)
	return publisher

if __name__ == '__main__':
	thisdir = os.path.dirname(__file__)
	templatesdir = os.path.join(thisdir, 'mySubfolder')
	templatesdir = os.path.abspath(templatesdir)
	loader = jinja2.FileSystemLoader(templatesdir)
	env = jinja2.Environment(loader=loader)
		
	from quixote.server.simple_server import run
	print 'creating demo listening on http://localhost:8080/'
	run(create_publisher, host='user-e47d8b.user.msu.edu', port=8080)
	#run(create_publisher, host='localhost', port=8080)
Beispiel #17
0
"""

from quixote.publish import Publisher
from quixote.directory import Directory


class RootDirectory(Directory):

    _q_exports = ['', 'hello']

    def _q_index(self):
        return '''<html>
                    <body>Welcome to the Quixote demo.  Here is a
                    <a href="hello">link</a>.
                    </body>
                  </html>
                '''

    def hello(self):
        return '<html><body>Hello world!</body></html>'


def create_publisher():
    return Publisher(RootDirectory(), display_exceptions='plain')


if __name__ == '__main__':
    from quixote.server.simple_server import run
    print 'creating demo listening on http://localhost:8080/'
    run(create_publisher, host='localhost', port=8080)
Beispiel #18
0
"""

from quixote.publish import Publisher
from quixote.directory import Directory, export


class RootDirectory(Directory):
    @export(name="")
    def index(self):
        return """<html>
                    <body>Welcome to the Quixote demo.  Here is a
                    <a href="hello">link</a>.
                    </body>
                  </html>
                """

    @export
    def hello(self):
        return "<html><body>Hello world!</body></html>"


def create_publisher():
    return Publisher(RootDirectory(), display_exceptions="plain")


if __name__ == "__main__":
    from quixote.server.simple_server import run

    print "creating demo listening on http://localhost:8080/"
    run(create_publisher, host="localhost", port=8080)
Beispiel #19
0
def main ():
    # create an http server bound to the host and port specified
    # and publish the Root instance.
    run(create_publisher, host="127.0.0.1", port=8080)
Beispiel #20
0
from quixote.server import simple_server
from quixote.publish import Publisher
from quixote.directory import Directory


class MySite(Directory):
    _q_exports = ["hello"]

    def hello(self):
        return "hello"


def factory():
    return Publisher(MySite())


if __name__ == "__main__":
    simple_server.run(factory, "localhost", 7080)