def __init__(self, **kwargs):
        super(HomePage, self).__init__(**kwargs)
        self.logVerbosity = 20
        #References the json file called local.json
        self.store = JsonStore(appPath + os.sep + 'local.json')
        print("whether previous exist = " +
              repr(self.store.exists('numEntries')))
        #Determines if the server initiation is correct (should only be a one time thing)
        isSuccessful = True

        if not os.path.isfile(appPath + os.sep + "client.log"):
            f = open(appPath + os.sep + "client.log", "w")
            f.close()
        client.init(appPath + os.sep + "client.log", self.logVerbosity)
        #self.macClass = GetMacAdd()
        #Checks if there is a file. If there is not, initiate all 4 necessary parts
        if (not self.store.exists('numEntries')):
            print("enter")
            #self.store.put("selfMac", value = self.macClass.getMacSelf()[0])
            self.store.put("selfMac", value="a1:4f:43:92:25:2e")
            tempSecret = client.initSelf(self.store.get("selfMac")["value"])
            if (tempSecret == 2):
                tempBut = Button(
                    text="Server Error, Please quit the app and try again (2)",
                    font_size=40)
                self.add_widget(tempBut)
                isSuccessful = False
                print("Server Error, Please quit the app and try again (2)")
            elif (tempSecret == 3):
                tempBut = Button(text="User already initiated (3)",
                                 font_size=40)
                self.add_widget(tempBut)
                isSuccessful = False
                print("User already initiated (3)")
            elif (tempSecret == 4):
                tempBut = Button(
                    text=
                    "Invalid Mac Address, Please quit the app and try again (4)",
                    font_size=40)
                self.add_widget(tempBut)
                isSuccessful = False
                print(
                    "Invalid Mac Address, Please quit the app and try again (4)"
                )
            else:
                self.store.put("secretKey", value=tempSecret)
                self.store.put("numEntries", value=0)
                self.store.put("macDict",
                               value={"a2:4f:43:92:25:2e": "07/21/2020"})
                self.store.put("recentTen", value=list())
                self.store.put("prevNetwork", value=dict())
        if (isSuccessful):
            self.options = ObjectProperty(None)
            #macClass variable is just used as a reference to be able to call the getMac class
            self.macClass = GetMacAdd()
            self.actualMac = self.macClass.getMac()
            self.status = "You are safe!"
Ejemplo n.º 2
0
    def __call__(self, filename):

        client.init(splitext(basename(filename))[0], self.level)

        if self.drop:
            client.dropdb(self.level)

        parser = OSMParser(concurrency=4,
                           ways_callback=self.way,
                           coords_callback=self.coord,
                           nodes_callback=self.node,
                           relations_callback=self.relation)
        parser.parse(filename)
        self.flush_buffer()
Ejemplo n.º 3
0
def main():

    resource.path.append('data')
    resource.reindex()
    font.add_directory('data/font')

    log.init()
    audio.init()
    client.init()
    server.init()
    options.init()
    director.init()

    clt = client.GameClient()
    clt.start()
    clt.stop()
Ejemplo n.º 4
0
def start():
    pg.init()

    pg.display.set_mode((width, height), flags=pg.SCALED | pg.RESIZABLE)
    pg.display.set_caption('card game')

    save.init()
    image_handler.init()
    spritesheet.init()
    customsheet.init()
    menu.init()
    client.init()
    game.init()
    network.init()
    builder.init()
    ui.init()

    main_menu = ui.Menu(get_objects=menu.main_menu)
    main_menu.run()

    pg.quit()
Ejemplo n.º 5
0
def process(things):

    global initPhase

    initPhase = True

    #print ("Initializing")

    client.init()

    while True:

        for thing in things:

            if (thing["type"] == "number"):
                processNumber(thing)

            if (thing["type"] == "switch"):
                processSwitch(thing)

        # initPhase nach 1. Durchgang abgeschlossen.
        initPhase = False
Ejemplo n.º 6
0
    def __init__(self, **kwargs):
        super(HomePage, self).__init__(**kwargs)
#References the json file called local.json
        self.store = JsonStore('local.json')
        print("whether previous exist = " + repr(self.store.exists('numEntries')))
#Determines if the server initiation is correct (should only be a one time thing)
        isSuccessful = True
        path = "/Users/ryan04px2021/Desktop/SAS/High_School/Junior_(11)/Afterschool_Activities/2020Summer/ActualSummer/CallForCode/CallForCode_COVID-19_Project/Kivy/Tutorials/11Test"
        client.init(path + "/sth.log", 10)
#Checks if there is a file. If there is not, initiate all 4 necessary parts
        if (not self.store.exists('numEntries')):
            print("enter")
            self.store.put("selfMac", value = "a2:4f:43:92:25:2e")
            tempSecret = client.initSelf(self.store.get("selfMac")["value"])
            if (tempSecret == 2):
                tempBut = Button(text = "Server Error, Please quit the app and try again (2)", font_size = 40)
                self.add_widget(tempBut)
                isSuccessful = False
            elif (tempSecret == 3):
                tempBut = Button(text = "User already initiated (3)", font_size = 40)
                self.add_widget(tempBut)
                isSuccessful = False
            elif (tempSecret == 4):
                tempBut = Button(text = "Invalid Mac Address, Please quit the app and try again (4)", font_size = 40)
                self.add_widget(tempBut)
                isSuccessful = False
            else:
                self.store.put("secretKey", value = tempSecret)
                self.store.put("numEntries", value = 0)
                self.store.put("macDict", value = dict())
                self.store.put("recentTen", value = list())
                self.store.put("prevNetwork", value = dict())
        if (isSuccessful):
            self.options = ObjectProperty(None)
#macClass variable is just used as a reference to be able to call the getMac class
            self.macClass = GetMacAdd()
            self.actualMac = self.macClass.getMac()
            self.status = "You are safe!"
Ejemplo n.º 7
0
def init():
    globals()['SAVE'] = save.get_save()
    game.init()
    spritesheet.init()
    client.init()
Ejemplo n.º 8
0
def reload():
    # Refresh the local store by reloading the files
    init()

    # Browse the uri passed in the GET request (if none, just show the START_URI)
    return browse()
Ejemplo n.º 9
0
def reload():
    # Refresh the local store by reloading the files
    init()

    # Browse the uri passed in the GET request (if none, just show the START_URI)
    return browse()
Ejemplo n.º 10
0
        if script_name:
            environ['SCRIPT_NAME'] = script_name
            path_info = environ['PATH_INFO']
            if path_info.startswith(script_name):
                environ['PATH_INFO'] = path_info[len(script_name):]

        scheme = environ.get('HTTP_X_SCHEME', '')
        if scheme:
            environ['wsgi.url_scheme'] = scheme
        return self.app(environ, start_response)


app = Flask(__name__)
Bootstrap(app)

# Do something special if the application root is other than the default ("/")
try:
    if config.BEHIND_PROXY:
        app.wsgi_app = ReverseProxied(app.wsgi_app)
except:
    print "WARNING: You are using an older version of the configuration file that does not set the 'BEHIND_PROXY' parameter, have a look at 'config-template.py' to see what to add."

app.debug = True
if (hasattr(config, 'DEBUG')):
    app.debug = config.DEBUG

# Initialize the client
client.init()

import views
Ejemplo n.º 11
0
def parse_args():
    parser = ArgumentParser()
    parser.add_argument('-c',
                        '--config',
                        help='Full path to config file.',
                        metavar='path')
    return parser.parse_args()


if __name__ == "__main__":
    args = parse_args()
    directory = os.path.dirname(sys.argv[0])
    if not directory.startswith('/'):
        directory = os.path.abspath("{}/{}".format(os.getcwd(), directory))

    config = yaml.load(file(args.config or 'rtmbot.conf', 'r'))
    debug = config["DEBUG"]
    api_client = client.init(config["SLACK_TOKEN"])
    bot = RtmBot(api_client)
    site_plugins = []
    files_currently_downloading = []
    job_hash = {}

    if config.has_key("DAEMON"):
        if config["DAEMON"]:
            import daemon
            with daemon.DaemonContext():
                main_loop()
    main_loop()
Ejemplo n.º 12
0
        '--config',
        help='Full path to config file.',
        metavar='path'
    )
    return parser.parse_args()


if __name__ == "__main__":
    args = parse_args()
    directory = os.path.dirname(sys.argv[0])
    if not directory.startswith('/'):
        directory = os.path.abspath("{}/{}".format(os.getcwd(),
                                directory
                                ))

    config = yaml.load(file(args.config or 'rtmbot.conf', 'r'))
    debug = config["DEBUG"]
    api_client = client.init(config["SLACK_TOKEN"])
    bot = RtmBot(api_client)
    site_plugins = []
    files_currently_downloading = []
    job_hash = {}

    if config.has_key("DAEMON"):
        if config["DAEMON"]:
            import daemon
            with daemon.DaemonContext():
                main_loop()
    main_loop()

Ejemplo n.º 13
0
    
def relation(relations):
    for osmid, tags, rels in relations:
        m = dict()
        m['type']='relation'
        m['osmid']=str(osmid)
        m['_id'] = str(osmid)
        m['members']=rels
        add_tags(m,tags)
        put_buffer(m)

# this is a stupid trick to ensure we don't have to deal
# with coords, but only with nodes...
def add_dummy_filter(tags):
    tags['__tag_dummy__']='foo'


if __name__ == "__main__":
    def usage():
        print "usage: importdb <file>"
        
    if (len(sys.argv) < 2):
        usage()
    elif not isfile(sys.argv[1]):
        usage()
    else:
        init(splitext(basename(sys.argv[1]))[0], 2)
        dropdb(2)
        importdb(sys.argv[1])
        print "Ways: %d Nodes: %d Coords: %d"%(waycount, nodecount, coordcount)
Ejemplo n.º 14
0
# import tensorflow
import client as test
import time

test.init(("172.16.10.227", 12347), ("172.16.10.227"), "172.16.10.223")

control = test.control
img = test.camera

# angle = [45,90,135,90]
# control.controlCameraAngle(18, 90)
# time.sleep(5)

# while True:
#     ret = img.findLine()
#     x = ret[0]
#     print(x)
#     if 220 < x < 420:
#         control.run(1,0.5)
#     elif 0< x <= 220:
#         control.left(0.5, 0.1)
#     elif x >= 420:
#         control.right(0.5,0.1)
#     else:
#         control.brake(5)
# time.sleep(0.01)

# while True:
#     for ag in angle:
#         control.controlCameraAngle(45, ag,1)
#
Ejemplo n.º 15
0
        addr = "0.0.0.0" # bind to any any
    try:
        server.listen(addr, sites[node].port, tweet_api.route)
    except KeyboardInterrupt:
        print '\n=====server terminated by user=====\n'

def parse_flag():
    if not sys.argv[1].isdigit():
        print "The site id \"" + sys.argv[1] + "\" is invalid. It should be an integer."
        exit(1)
    my_node = int(sys.argv[1])
    config_file = "config.json"
    data_file = "datafile%d.json"%(my_node,)
    my_site, sites = config.load(config_file, my_node)
    if my_site == None:
        print "The site id \"" + sys.argv[1] + "\" is invalid. It cannot be found in the config file."
        exit(1)
    print "I am User '%s' Addr '%s' Node %d"%(my_site.name, my_site.addr, my_site.node)
    print "I know these users:"
    for site in sites:
        print "User '%s' Addr '%s' Node %d"%(site.name, site.addr, site.node)
    return my_node, sites, data_file

if __name__ == '__main__':
    node, sites, data_file = parse_flag()
    Process(target=init_server, args=(node, sites, data_file)).start()
    try:
        client.init(node, sites)
    except KeyboardInterrupt:
        print '\n=====client terminated by user=====\n'
Ejemplo n.º 16
0
import service

sys.path.append(os.getcwd())


def parse_args():
    parser = ArgumentParser()
    parser.add_argument(
        '-c',
        '--config',
        help='Full path to config file.',
        metavar='path'
    )
    return parser.parse_args()

# load args with config path
args = parse_args()
config = None
with open(args.config or 'rtmbot.conf', 'r') as f:
    config = yaml.load(f)

token = config.get('SLACK_TOKEN')
host = config.get('HOST')
service.slack = service.SlackService(token, host)

bot = client.init(config)
try:
    bot.start()
except KeyboardInterrupt:
    sys.exit(0)
Ejemplo n.º 17
0
        scheme = environ.get('HTTP_X_SCHEME', '')
        if scheme:
            environ['wsgi.url_scheme'] = scheme
        return self.app(environ, start_response)


app = Flask(__name__)
Bootstrap(app)
cache = Cache(app,config={'CACHE_TYPE': 'simple'})

# Do something special if the application root is other than the default ("/")
try:
    if config.BEHIND_PROXY:
        app.wsgi_app = ReverseProxied(app.wsgi_app)
except:
    print "WARNING: You are using an older version of the configuration file that does not set the 'BEHIND_PROXY' parameter, have a look at 'config-template.py' to see what to add."

app.debug = True
if (hasattr(config, 'DEBUG')):
    app.debug = config.DEBUG

import views

if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true":
    # The app is not in debug mode or we are in the reloaded process
    client.init()

def run():
    app.run(host="0.0.0.0", port=(config.PORT if hasattr(config, 'PORT') else 5000))
Ejemplo n.º 18
0
import client
import service

sys.path.append(os.getcwd())


def parse_args():
    parser = ArgumentParser()
    parser.add_argument('-c',
                        '--config',
                        help='Full path to config file.',
                        metavar='path')
    return parser.parse_args()


# load args with config path
args = parse_args()
config = None
with open(args.config or 'rtmbot.conf', 'r') as f:
    config = yaml.load(f)

token = config.get('SLACK_TOKEN')
host = config.get('HOST')
service.slack = service.SlackService(token, host)

bot = client.init(config)
try:
    bot.start()
except KeyboardInterrupt:
    sys.exit(0)
    networked = True
    client = GameClient(eventManager,host=s.host,port=1567)

	#wait until the client is assigned an ID before proceeding
    while client.ID == None:
        import time
        time.sleep(.02)
    print 'Got an ID',client.ID
    clientID = client.ID

    ui.setClientID(clientID)

    wManipulator = WorldManipulator(eventManager,w,networked,gameClientID = clientID)
    
    #generate the resources in the server, the existance of these
    #resources will propogate through to every client when they connect
    w._generateResources()
    
    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())

    return eventManager.eventTypesToListeners

if __name__ == '__main__':
    #FIXME: Very little implemented here.
    #Connect to server
    s = BroadcastServer(port = 1567, host = '192.168.1.103')
    s.listenAndConnect()

    init(server=s)