コード例 #1
0
def main():
    #setting time
    startTime = time.time()

    #set section
    version_check()
    conf.init()
    print("\n")

    #main variables crate
    world = World(win_size=(800, 600))
    world.world_to_camera_coord()
    world.project()

    #game init section
    pygame.init()

    world.draw()

    #time to render
    endTime = time.time()
    print("time to complete: " + str(endTime - startTime) + "s.")

    #main loop
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        # pygame.display.update() #it seems have problems
        pygame.display.flip()
コード例 #2
0
ファイル: main.py プロジェクト: bbugh/InputScope
def main():
    """Program entry point."""
    conf.init()

    if wx:
        name = urllib.quote_plus("-".join([conf.Title, conf.DbPath]))
        singlechecker = wx.SingleInstanceChecker(name)
        if singlechecker.IsAnotherRunning(): sys.exit()

        app = MainApp(redirect=True) # redirect stdout/stderr to wx popup
        locale = wx.Locale(wx.LANGUAGE_ENGLISH) # Avoid dialog buttons in native language
        app.MainLoop() # stdout/stderr directed to wx popup
    else:
        model = Model()
        if tk:
            widget = tk.Tk() # Use Tkinter instead to get screen size
            size = [0, 0, widget.winfo_screenwidth(), widget.winfo_screenheight()]
            model.log_resolution([size])
            widget.destroy()
        print("wxPython not available, using basic command line interface.")
        print("Web interface running at %s" % conf.WebUrl)
        try:
            model.run()
        except IOError as e:
            if e.errno != errno.EINTR: raise # Interrupted syscall, probably sleep
        except KeyboardInterrupt:
            model.stop()
コード例 #3
0
ファイル: zqueue.py プロジェクト: sauravcsvt/geocoding
def init(args=None):
    # init logger
    # load/get the config
    # eventually this needs a search path for the config
    # should be env(QFU_CONFIG);./queue.conf;/etc/embers/queue.conf;tcp://localhost:3473
    # use 3473 as the global control channel
    cf = None
    conf.init(args)
コード例 #4
0
ファイル: zqueue.py プロジェクト: runninghack/twitter-geo
def init(args=None):
    # init logger
    # load/get the config
    # eventually this needs a search path for the config
    # should be env(QFU_CONFIG);./queue.conf;/etc/embers/queue.conf;tcp://localhost:3473
    # use 3473 as the global control channel
    cf = None
    conf.init(args)
コード例 #5
0
ファイル: listener.py プロジェクト: Jiajing-Hu/carl
def main():
    """Entry point for stand-alone execution."""
    conf.init(), db.init(conf.DbPath)
    inqueue = LineQueue(sys.stdin).queue
    outqueue = type("", (), {"put": lambda self, x: print("\r%s" % x, end=" ")})()
    if "--quiet" in sys.argv: outqueue = None
    if conf.MouseEnabled:    inqueue.put("mouse_start")
    if conf.KeyboardEnabled: inqueue.put("keyboard_start")
    start(inqueue, outqueue)
コード例 #6
0
ファイル: webui.py プロジェクト: Jiajing-Hu/carl
def init():
    """Initialize configuration and web application."""
    global app
    if app: return app
    conf.init(), db.init(conf.DbPath, conf.DbStatements)

    bottle.TEMPLATE_PATH.insert(0, conf.TemplatePath)
    app = bottle.default_app()
    bottle.BaseTemplate.defaults.update(get_url=app.get_url)
    return app
コード例 #7
0
def init():
    """Initialize configuration and web application."""
    global app
    if app: return app
    conf.init(), db.init(conf.DbPath, conf.DbStatements)
    try: db.execute("PRAGMA journal_mode = WAL")
    except Exception: pass

    bottle.TEMPLATE_PATH.insert(0, conf.TemplatePath)
    app = bottle.default_app()
    bottle.BaseTemplate.defaults.update(get_url=app.get_url)
    return app
コード例 #8
0
ファイル: iqueue.py プロジェクト: sauravcsvt/geocoding
def init(args=None):
    # init logger
    # load/get the config
    # eventually this needs a search path for the config
    # should be env(QFU_CONFIG);./queue.conf;/etc/embers/queue.conf;tcp://localhost:3473
    # use 3473 as the global control channel
    global SERVICE, INITTED
    cf = None
    conf.init(args)
    if args and args.service:
        SERVICE = args.service
    else:
        SERVICE = os.environ.get('UPSTART_JOB', "")

    INITTED = True
コード例 #9
0
ファイル: iqueue.py プロジェクト: runninghack/twitter-geo
def init(args=None):
    # init logger
    # load/get the config
    # eventually this needs a search path for the config
    # should be env(QFU_CONFIG);./queue.conf;/etc/embers/queue.conf;tcp://localhost:3473
    # use 3473 as the global control channel
    global SERVICE, INITTED
    cf = None
    conf.init(args)
    if args and args.service:
        SERVICE = args.service
    else:
        SERVICE = os.environ.get('UPSTART_JOB', "")

    INITTED = True
コード例 #10
0
ファイル: init.py プロジェクト: iPHiLGG/yt-prs
def first_time_setup():
    """
        Set config file when the program is started for the first time.
    """
    conf.init()
    print("Pour trouver le ID de votre chaîne YouTube, allez sur:\n" +
          " https://www.youtube.com/account_advanced\n")
    id = input("YouTube Channel ID: ")
    print("\n\nPour obtenir une clé API de Google, allez sur:\n" +
          " https://console.developers.google.com dans la section" +
          " 'Credentials' -> 'Create credentials' -> 'API key' ->" +
          " 'Server key'.\n")
    key = input("Clé API: ")
    print("\n* Notice: Ne partager pas votre clé API avec personne aussinon" +
          " votre quota pourrait être utilisé!\n")
    autre.input_block()
    conf.add("channel_id", id)
    conf.add("api_key", key)
コード例 #11
0
ファイル: main.py プロジェクト: Jiajing-Hu/carl
def main():
    """Program entry point."""
    conf.init(), db.init(conf.DbPath, conf.DbStatements)

    if wx:
        MainApp(redirect=True).MainLoop()  # stdout/stderr directed to wx popup
    else:
        model = Model(lambda x: sys.stderr.write("\r%s" % x))
        if tk:
            widget = tk.Tk()  # Use Tkinter instead to get screen size
            size = widget.winfo_screenwidth(), widget.winfo_screenheight()
            model.log_resolution(size)
        print("wxPython not available, using basic command line interface.")
        print("Web interface running at %s" % conf.WebUrl)
        try:
            model.run()
        except KeyboardInterrupt:
            model.stop()
コード例 #12
0
ファイル: listener.py プロジェクト: bbugh/InputScope
def start(inqueue, outqueue=None):
    """Starts the listener with incoming and outgoing queues."""
    conf.init(), db.init(conf.DbPath, conf.DbStatements)

    # Carry out db update for tables lacking expected new columns
    for (table, col), sqls in conf.DbUpdateStatements:
        if any(col == x["name"]
               for x in db.execute("PRAGMA table_info(%s)" % table)):
            continue  # for
        for sql in sqls:
            db.execute(sql)

    try:
        db.execute("PRAGMA journal_mode = WAL")
    except Exception:
        pass

    try:
        Listener(inqueue, outqueue).run()
    except KeyboardInterrupt:
        pass
コード例 #13
0
ファイル: core.py プロジェクト: kundouzhishou/kundouzhishou
def execute_sql(sql):
	dirpath = os.path.dirname(os.path.abspath(__file__))
	conf.init(dirpath + "/db.ini")

	section = 'mysql'
	host = conf.get_value(section, "host")
	username = conf.get_value(section, "username")
	password = conf.get_value(section, "password")
	database = conf.get_value(section, "database")
	db = MySQLdb.connect(host,username,password,database)
	cursor = db.cursor()
	
	# sql = db.escape_string(sql)
	
	logger.debug("execute sql:" + sql)

	try:
		cursor.execute(sql)
		db.commit()
	except Exception,err:
		print(err)
		db.rollback()
コード例 #14
0
def execute_sql(sql):
    dirpath = os.path.dirname(os.path.abspath(__file__))
    conf.init(dirpath + "/db.ini")

    section = 'mysql'
    host = conf.get_value(section, "host")
    username = conf.get_value(section, "username")
    password = conf.get_value(section, "password")
    database = conf.get_value(section, "database")
    db = MySQLdb.connect(host, username, password, database)
    cursor = db.cursor()

    # sql = db.escape_string(sql)

    logger.debug("execute sql:" + sql)

    try:
        cursor.execute(sql)
        db.commit()
    except Exception, err:
        print(err)
        db.rollback()
コード例 #15
0
def init(args=None):
    cf = None
    conf.init(args)
コード例 #16
0
    start_train.exposed = True
    start_train._cp_config = {'response.stream': True}

    def check_train(self):
        res = []
        res.append('<img src="/img/loss.png"></img>')
        res.append(self.home_link())
        res.append('<a href="/manage_train">train</a><br>')
        return self.easy_page("".join(res))

    check_train.exposed = True


if __name__ == "__main__":
    conf.init('../config.json')
    # Define the global configuration settings of CherryPy
    global_conf = {
        'global': {
            'server.socket_host': '0.0.0.0',
            'server.socket_port': conf.web_app_server_port,
            'server.protocol_version': 'HTTP/1.1'
        }
    }
    current_dir = os.path.dirname(os.path.abspath(__file__))
    print("current_dir ", current_dir)
    application_conf = {
        '/': {
            'tools.staticdir.root': current_dir
        },
        '/favicon.ico': {
コード例 #17
0
ファイル: master.py プロジェクト: zhcn/amazon
        rlist.append(self.tcpCliSock)
        while True:
            rl,wl,el = select.select(rlist,wlist,xlist)
            for s in rl:
                data = s.recv(BUFSIZE)
                print data
                if(data=='finished'):
                    print self.server+' finished'
                    return
def send_data(conf_path):
    task_split.task_split(conf_path)
                
if __name__=='__main__':
    #ips = readConf()
    conf_path = '../conf/conf.txt'
    conf.init(conf_path)
    send_data(conf_path)
    #exit()
    config = conf.readConf(conf_path)
    ips = config['ips']
    ths = []
    for ip in ips:
        ths.append(Demon(ip))
    for t in ths:
        t.start()
    for t in ths:
        t.join()
    print 'Demon Stopped'
                
                
            
コード例 #18
0
ファイル: filter.py プロジェクト: xinshea/proxyedit
        cD = self._get_dict()

        if len(args)<2:
            if len(args)==0:
                v = True
            else:
                v = args[0]
            self.parent[self.key] = v
        elif len(args)==2:
            cD[args[0]] = args[1]


confDict = ProxyConf()
ProxyConf.add_extension(Match())
ProxyConf.add_extension(NoProxyCache())
conf.init(confDict)
conf = confDict
print(conf)

def nocache(flow):
    flow.response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, max-age=0"


def realv(v, flow):
    if callable(v):
        return v(flow)
    else:
        return v

def process_headers(flow, headers, direction):
    if direction == "REQUEST":
コード例 #19
0
ファイル: simpleauth.py プロジェクト: frankh/simpleauth
		metavar='create',
		action='store_const',
		const=True, 
		default=False,
		help='create a new database'
	)

	parser.add_argument(
		'-d', 
		'--database', 
		metavar='db_path',
		type=str,
		default='users.sqlite',
		help='the sqlite db file to use'
	)

	args = parser.parse_args()

	conf.DB_NAME = args.database
	conf.init()

	if args.create:
		print('Creating new db "{db}"'.format(db=args.database))
		utils.create_db()
	else:
		simpleauth.listen(args.port)
		print('Listening on port {port}'.format(port=args.port))
		print('Using user db "{db}"'.format(db=args.database))
		iol = tornado.ioloop.IOLoop.instance()
		iol.start()
コード例 #20
0
ファイル: client_main.py プロジェクト: zhcn/amazon
        self.tid = tid
        self.task_num = task_num

    def run(self):
        try:
            #os.system('python getIsbn.py '+str(self.tid)+' '+str(self.task_num))
            os.system('python ' + process + ' ' + str(self.tid) + ' ' +
                      str(self.task_num))
        except Exception, e:
            print e


if __name__ == '__main__':
    ths = []
    conf_file = '../conf/conf.txt'
    conf.init(conf_file)
    config = conf.readConf(conf_file)
    task_num = config['task_num']
    #os.system('python ./urls/split.py '+str(task_num))
    data_file = config['data_file']
    data_dir = config['data_dir']
    destdir = config['split_tmp']
    split_tmp = destdir
    process = config['process']
    merge = config['merge']
    client_result = config['client_result']
    client_union = config['client_union']
    os.system('rm -rf ' + split_tmp)
    os.system('rm -rf ' + client_result)
    os.system('rm -rf ' + client_union)
    os.system('mkdir ' + split_tmp)
コード例 #21
0
ファイル: __init__.py プロジェクト: altai/focus-selenium-test
import collections
import yaml
import string

import conf
from lettuce import step, world, before, after
from lettuce_bunch.special import get_current_bunch_dir

from selenium import webdriver

from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import Select
from pdb import Pdb

dir_path = get_current_bunch_dir()
conf.init(dir_path)
config_file = os.path.join(dir_path, "config.yaml")
config = conf.load_yaml_config(config_file)
bunch_working_dir = dir_path


OUTPUT_GARBAGE = ['DeprecationWarning', 'import md5', 'import sha', 'DEBUG nova.utils', 'is deprecated', 'Warning:', 'PowmInsecureWarning:', 'RandomPool_DeprecationWarning:']
SSH_PRIVATE_KEY_PATH = os.path.join(get_current_bunch_dir(), config['keypair']['private-file'])
SSH_OPTS = '-T -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'


def trace_me(*args, **kwargs):
    import pdb; pdb.set_trace()


コード例 #22
0
ファイル: resource.py プロジェクト: runninghack/twitter-geo
def init(args=None):
	cf = None
	conf.init(args)
コード例 #23
0
ファイル: client_main.py プロジェクト: zhcn/amazon
class MyThread(Thread):
    def __init__(self,tid,process,task_num):
        Thread.__init__(self)
        self.tid = tid
        self.task_num = task_num
    def run(self):
        try:
            #os.system('python getIsbn.py '+str(self.tid)+' '+str(self.task_num))
            os.system('python '+process+' '+str(self.tid)+' '+str(self.task_num))
        except Exception,e:
            print e
            
if __name__=='__main__':
    ths = []
    conf_file = '../conf/conf.txt'
    conf.init(conf_file)
    config = conf.readConf(conf_file)
    task_num = config['task_num']
    #os.system('python ./urls/split.py '+str(task_num))
    data_file = config['data_file']
    data_dir = config['data_dir']
    destdir = config['split_tmp']
    split_tmp = destdir
    process = config['process']
    merge = config['merge']
    client_result = config['client_result']
    client_union = config['client_union']
    os.system('rm -rf '+split_tmp)
    os.system('rm -rf '+client_result)
    os.system('rm -rf '+client_union)
    os.system('mkdir '+split_tmp)
コード例 #24
0
ファイル: master.py プロジェクト: zhcn/amazon
        while True:
            rl, wl, el = select.select(rlist, wlist, xlist)
            for s in rl:
                data = s.recv(BUFSIZE)
                print data
                if (data == 'finished'):
                    print self.server + ' finished'
                    return


def send_data(conf_path):
    task_split.task_split(conf_path)


if __name__ == '__main__':
    #ips = readConf()
    conf_path = '../conf/conf.txt'
    conf.init(conf_path)
    send_data(conf_path)
    #exit()
    config = conf.readConf(conf_path)
    ips = config['ips']
    ths = []
    for ip in ips:
        ths.append(Demon(ip))
    for t in ths:
        t.start()
    for t in ths:
        t.join()
    print 'Demon Stopped'
コード例 #25
0
ファイル: predict.py プロジェクト: alanswx/shark
import argparse
import time
import json
import traceback
import numpy as np
import keras
import zmq
import conf
import models
from PIL import Image
from PIL import ImageEnhance
import random
import load_data
import conf

conf.init()


def go(model_path, pred_address, pred_control_address):
    '''
    Start the server
    '''
    context = zmq.Context()
    socket = context.socket(zmq.REP)
    connect_str = "tcp://%s:%s" % ('*', pred_address[1])
    print('pred listening on', connect_str)
    rc = socket.bind(connect_str)

    cont_socket = context.socket(zmq.REP)
    connect_str = "tcp://%s:%s" % ('*', pred_control_address[1])
    print('pred contl listening on', connect_str)
コード例 #26
0
from lettuce import step, world
from nose.tools import assert_equals, assert_true, assert_false
import utils
from utils import onfailure
import os
import lettuce_bunch.special
import conf
from lettuce_bunch.special import get_current_bunch_dir

get_current_bunch_dir()

dir_path = conf.get_current_module_path(__file__)

conf.init(dir_path)
config_file = os.path.join(dir_path, "config.yaml")
config = conf.load_yaml_config(config_file)
bunch_working_dir = dir_path


def dump(obj):
    for attr in dir(obj):
        print "obj.%s = %s" % (attr, getattr(obj, attr))


mysql_admin = config['db']['admin']
mysql_admin_pwd = config['db']['admin_pwd']


class step_assert(object):
    def __init__(self, step):
        self.step = step
コード例 #27
0
ファイル: filter.py プロジェクト: emasab/proxyedit
        cD = self._get_dict()

        if len(args)<2:
            if len(args)==0:
                v = True
            else:
                v = args[0]
            self.parent[self.key] = v
        elif len(args)==2:
            cD[args[0]] = args[1]


confDict = ProxyConf()
ProxyConf.add_extension(Match())
ProxyConf.add_extension(NoProxyCache())
conf.init(confDict)
conf = confDict
print(conf)

def nocache(flow):
    flow.response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, max-age=0"


def realv(v, context, flow):
    if callable(v):
        return v(context, flow)
    else:
        return v

def process_headers(flow, headers, direction):
    if direction == "REQUEST":
コード例 #28
0
ファイル: listener.py プロジェクト: Jiajing-Hu/carl
def start(inqueue, outqueue=None):
    """Starts the listener with incoming and outgoing queues."""
    conf.init(), db.init(conf.DbPath)
    Listener(inqueue, outqueue).run()