示例#1
0
 def aanbieden(self, data):
     api = Api()
     db = DataBase()
     if db.saveAanbieder(data['titel'], api.getCurrentTime()):
         self.aanbieder.configure(text="Gasten lijst",
                                  command=lambda controller=self.controller:
                                  self.gastenlijst(controller, data))
示例#2
0
 def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)
     self.configure(bg=FL_BG_COLOR)
     button = tk.Button(self, text="Uitloggen",
                        command=lambda: self.Logout(controller), font=FL_BASE_FONT, bg="#670000",
                        fg=FL_TEXT_COLOR, relief='ridge', activebackground="#b26666",
                        activeforeground=FL_TEXT_COLOR)
     button.grid(row=1, column=5, columnspan=2, ipadx=100)
     label = tk.Label(self, text="Films", font=FL_TITLE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
     label.grid(row=1, column=0, sticky='w', padx=25, columnspan=5)
     uitleg = tk.Label(self,
                       text="Klik op een plaatje of titel voor informatie over de film of om een kaartje te kopen.",
                       font=FL_BASE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
     uitleg.grid(row=2, sticky='w', padx=25, pady=50, columnspan=5)
     apis = Api()
     movie_list = apis.getMovieList(apis.getCurrentTime())
     col = 0
     for titel in movie_list:
         images = ImageTk.PhotoImage(Image.open(str(titel['image'])))
         b1 = tk.Button(self, command=lambda titel=titel: self.details(controller, titel), image=images, height=290,
                        width=168)
         b1.grid(row=3, column=col, pady=25, padx=10)
         # save the button image from garbage collection!
         b1.image = images
         tijd = datetime.datetime.fromtimestamp(int(titel['starttijd']))
         titelbtn = tk.Button(self, command=lambda titel=titel: self.details(controller, titel), text=titel['titel'],
                              font=("Tahoma", 10, "bold"), bg=FL_BG_COLOR, fg=FL_TEXT_COLOR, relief='ridge',
                              activebackground=FL_BG_COLOR, activeforeground=FL_TEXT_COLOR)
         titelbtn.grid(row=4, column=col)
         starttijd = tk.Label(self, text=str(tijd), font=FL_BASE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
         starttijd.grid(row=5, column=col)
         col += 1
示例#3
0
    def __direction_logic(self):
        # Determine if someone has moved to the left
        right_sensor: UltraSonic = self.__ultrasonics[min(
            [x['trig_pin'] for x in ULTRASONIC_PINS])]
        left_sensor: UltraSonic = self.__ultrasonics[max(
            [x['trig_pin'] for x in ULTRASONIC_PINS])]

        if right_sensor.timestamp is None or left_sensor.timestamp is None:
            return

        diff: timedelta = right_sensor.timestamp - left_sensor.timestamp

        log.debug(f'Time diff {diff}')

        if timedelta(seconds=-2) < diff < timedelta(seconds=2):
            if diff < timedelta(seconds=0):
                msg = 'Person walked from right to left'
                log.info(msg)
                print(msg)
                if Board.POST_DATA:
                    Api.increment(True)
            elif diff > timedelta(seconds=0):
                msg = 'Person walked from left to right'
                log.info(msg)
                print(msg)
                if Board.POST_DATA:
                    Api.increment(False)
            left_sensor.timestamp = right_sensor.timestamp = datetime.now()
示例#4
0
 def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)
     self.configure(bg=FL_BG_COLOR)
     button = tk.Button(self,
                        text="Uitloggen",
                        command=lambda: self.Logout(controller),
                        font=FL_BASE_FONT,
                        bg="#670000",
                        fg=FL_TEXT_COLOR,
                        relief='ridge',
                        activebackground="#b26666",
                        activeforeground=FL_TEXT_COLOR)
     button.grid(row=1, column=5, columnspan=2, ipadx=100)
     label = tk.Label(self,
                      text="Films",
                      font=FL_TITLE_FONT,
                      bg=FL_BG_COLOR,
                      fg=FL_TEXT_COLOR)
     label.grid(row=1, column=0, sticky='w', padx=25, columnspan=5)
     uitleg = tk.Label(
         self,
         text=
         "Klik op een plaatje of titel voor informatie over de film of om een kaartje te kopen.",
         font=FL_BASE_FONT,
         bg=FL_BG_COLOR,
         fg=FL_TEXT_COLOR)
     uitleg.grid(row=2, sticky='w', padx=25, pady=50, columnspan=5)
     apis = Api()
     movie_list = apis.getMovieList(apis.getCurrentTime())
     col = 0
     for titel in movie_list:
         images = ImageTk.PhotoImage(Image.open(str(titel['image'])))
         b1 = tk.Button(
             self,
             command=lambda titel=titel: self.details(controller, titel),
             image=images,
             height=290,
             width=168)
         b1.grid(row=3, column=col, pady=25, padx=10)
         # save the button image from garbage collection!
         b1.image = images
         tijd = datetime.datetime.fromtimestamp(int(titel['starttijd']))
         titelbtn = tk.Button(
             self,
             command=lambda titel=titel: self.details(controller, titel),
             text=titel['titel'],
             font=("Tahoma", 10, "bold"),
             bg=FL_BG_COLOR,
             fg=FL_TEXT_COLOR,
             relief='ridge',
             activebackground=FL_BG_COLOR,
             activeforeground=FL_TEXT_COLOR)
         titelbtn.grid(row=4, column=col)
         starttijd = tk.Label(self,
                              text=str(tijd),
                              font=FL_BASE_FONT,
                              bg=FL_BG_COLOR,
                              fg=FL_TEXT_COLOR)
         starttijd.grid(row=5, column=col)
         col += 1
示例#5
0
 def aanmelden(self, controller):
     if self.naam.get() == '' or self.email.get() == '':
         self.error.configure(text='Vul alle gegevens in.')
     else:
         api = Api()
         db = DataBase()
         ucode = uuid4().hex
         db.saveFilm(self.data["titel"], self.data["aanbieder"], api.getCurrentTime(), ucode, self.naam.get(), self.email.get())
         controller.show_frame(qrFrame, ucode)
示例#6
0
 def aanmelden(self, controller):
     if self.naam.get() == '' or self.email.get() == '':
         self.error.configure(text='Vul alle gegevens in.')
     else:
         api = Api()
         db = DataBase()
         ucode = uuid4().hex
         db.saveFilm(self.data["titel"], self.data["aanbieder"],
                     api.getCurrentTime(), ucode, self.naam.get(),
                     self.email.get())
         controller.show_frame(qrFrame, ucode)
示例#7
0
 def setData(self, data):
     api = Api()
     self.data = data
     images = ImageTk.PhotoImage(Image.open(str(data["image"])))
     self.foto.configure(image=images)
     self.foto.image = images
     data = api.getMovieDescription(data["titel"], api.getCurrentTime())
     self.titel['text'] = data['titel']
     self.beschrijving["text"] = data["synopsis"]
     self.jaar["text"] = data["jaar"]
     self.cast["text"] = data["cast"]
     self.genre["text"] = data["genre"]
     self.duur["text"] = data["duur"]
     self.zender["text"] = data["zender"]
示例#8
0
 def setData(self, data):
     api = Api()
     self.data = data
     images = ImageTk.PhotoImage(Image.open(str(data["image"])))
     self.foto.configure(image=images)
     self.foto.image = images
     data = api.getMovieDescription(data["titel"], api.getCurrentTime())
     self.titel['text'] = data['titel']
     self.beschrijving["text"] = data["synopsis"]
     self.jaar["text"] = data["jaar"]
     self.cast["text"] = data["cast"]
     self.genre["text"] = data["genre"]
     self.duur["text"] = data["duur"]
     self.zender["text"] = data["zender"]
示例#9
0
def index():
    data = {
        'logAll':           getLastLogAll(),
        'logDeploySuccess': getLastLogDeploySuccess(),
        'showDetails':      None,
        'highlight':        None,
        'servers':          Api.getServers(),
        'branches':         Api.getBranches()
    }
    if request.query.show:
        data['showDetails'] = request.query.show
        data['highlight'] = request.query.show
    if request.query.highlight:
        data['highlight'] = request.query.highlight
    return template('templates/index', data=data)
示例#10
0
    def requestComments(self, data, data_type, owner_id):
        if str(owner_id) != Api.getUserId():
            return

        c.log('debug',
              'Requesting comments for %s %i' % (data_type, data['id']))

        if data_type == 'photo':
            api_method = 'photos.getComments'
            api_id_name = 'photo_id'
        elif data_type == 'video':
            api_method = 'video.getComments'
            api_id_name = 'video_id'
        elif data_type == 'wall':
            api_method = 'wall.getComments'
            api_id_name = 'post_id'
        else:
            c.log(
                'warning',
                'Unable to request comments for %s %i - not implemented' %
                (data_type, data['id']))
            return

        if 'comments' not in data:
            data['comments'] = {}
        if not isinstance(data['comments'], dict):
            data['comments'] = {}

        req_data = {
            'owner_id': int(owner_id),
            api_id_name: int(data['id']),
            'count': 100,
            'offset': 0
        }

        while True:
            subdata = Api.request(api_method, req_data)
            if subdata == None:
                return
            count = subdata['count']
            subdata = subdata['items']
            for d in subdata:
                data['comments'][str(d['date'])] = d
                self.loadAttachments(data['comments'][str(d['date'])])

            req_data['offset'] += 100
            if req_data['offset'] >= count:
                break
示例#11
0
def addToSession(self,commandList):
    globals = self.globals
    sessionKey, apiKey, apiProjectName, apiClassName, gitUrl = getCredentials(self,commandList)
    session = getSession(self,sessionKey)
    if apiKey and apiProjectName and apiClassName and gitUrl :
        try :
            importApplicationScript = ADD_APPLICATION_FILE_SCRIPT.replace(PROJECT_TOKEN,apiProjectName)
            importApplicationScript = importApplicationScript.replace(APPLICATION_TOKEN,apiClassName)
            if self.repository.existsByKeyAndCommit(apiKey,Api) :
                api = self.repository.findByKeyAndCommit(apiKey,Api)
                if api not in session.apiList :
                    session.apiList.append(api)
                    self.repository.saveAllAndCommit(session.apiList)
                    self.printSuccess(f'"{api.key}" : "{api.className}" added successfully')
                else :
                    self.printWarning(f'"{api.key}" : "{api.className}" api already belongs to "{session.key}" session')
            else :
                newApi = Api(apiKey,apiProjectName,apiClassName,gitUrl,importApplicationScript,[session])
                newApi = self.repository.saveAndCommit(newApi)
                self.printSuccess(f'"{newApi.key}" : "{newApi.className}" added successfully')
            return
        except Exception as exception :
            errorMessage = str(exception)
    else :
        errorMessage = 'failed to parse parameters'
    log.error(self.__class__, f'failed to add api due {commandList} command list', errorMessage)
示例#12
0
def requestMessages(request, msgs_data):
    request['count'] = 200
    request['offset'] = -200
    if len(msgs_data['log']) == 0:
        request['rev'] = 1
        request['offset'] = 0
    else:
        request['start_message_id'] = msgs_data['log'][-1]['id']

    while True:
        data = Api.request('messages.getHistory', request)
        if data == None:
            return
        count = data['count']
        data = data['items']

        if len(data) == 0:
            c.log('info', '  no new messages %i (%i)' % (len(msgs_data['log']), count))
            break

        # Switch to get history by message id
        if 'start_message_id' not in request:
            request['offset'] = -200
            request.pop('rev', None)
        else:
            data.reverse()

        processMessages(data)
        msgs_data['log'].extend(data)

        request['start_message_id'] = data[-1]['id']
        c.log('info', '  loaded %i, stored %i (%i)' % (len(data), len(msgs_data['log']), count))
        if len(data) < 200:
            c.log('info', '  done')
            break
示例#13
0
    def DoGet(self, aRequest):
        Header = THeader()

        R    = None 
        Code = 200
        Content = aRequest.get('content', '{}')

        Path = aRequest.get('path')
        Func = Api.Load(Path)
        if (Func):
            try:
                Content = json.loads(Content)
                try:
                    R = Func(Content)
                    if (R is None):
                        R = {}
                    R = json.dumps(R)
                except Exception as e:
                    Code = 400
                    R = Log.Print(1, self.__class__.__name__, 'DoGet()', e)
            except:
                Code = 400
                R = Log.Print(1, self.__class__.__name__, 'DoGet()', 'json error %s' % Content)
        else:
            Code = 404
            R = 'Error: %s %s' % (Header.Codes.get(Code), Path)

        self.Timer.Init()
        print('In:', Path, Content, 'Out:', R)

        Header.AddCode(Code)
        Header.AddData(R)
        return str(Header)
示例#14
0
 def getPairsFullInfo():
     """
                     Získá aktuální obchodovatelné páry z btc-e.com pomocí modulu api.py
                     a porovná je s páry, které chceme obchodovat v nastavení.
                     Pokud je pár v obou skupinách, vytvoří pro něj řádek v databázi.
                     """
     get = Api.PublicApi()
     raw = dict(get.getPublicInfo())
     rawpairsinfo = raw["pairs"]
     tradingpairs = self.config.tradingPairs
     pairsinfolist = []
     while True:
         for key, value in rawpairsinfo.items():
             if key in tradingpairs:
                 pairdict = {
                     "pair": key,
                     "decimal": value["decimal_places"],
                     "min_price": value["min_price"],
                     "max_price": value["max_price"],
                     "fee": value["fee"],
                     "min_amount": value["min_amount"]
                 }
                 pairsinfolist.append(pairdict)
                 continue
         return pairsinfolist
    def do_startup(self):
        Gtk.Application.do_startup(self)

        #self.settings = Gio.Settings.new(self.SETTINGS_KEY)
        self.builder = Gtk.Builder()
        self.builder.add_from_file("../resources/GladeFiles/SmsWindow.glade")

        screen = Gdk.Screen.get_default()

        css_provider = Gtk.CssProvider()
        css_provider.load_from_path('../resources/style.css')

        context = Gtk.StyleContext()
        context.add_provider_for_screen(screen, css_provider,
                                        Gtk.STYLE_PROVIDER_PRIORITY_USER)

        if self.is_config_valid() == False:
            self.show_settings_window()
        self.api = Api.ConnectivityManager(self)
        self.api.connect("authenticated", self.on_authorized)
        self.api.connect("authenticatation_failed",
                         self.on_authorization_failed)
        self.api.connect("ws_opened", self.on_ws_opened)
        self.api.connect("ws_closed", self.on_ws_closed)
        self.api.connect("ws_message_recived", self.on_message_recived)

        self.api.authorize()
示例#16
0
def main(myArgs):
    parser = OptionParser()
    parser.add_option("-b", help="server ip address")
    parser.add_option("-i", help="id")
    (options, args) = parser.parse_args()
    if options.i is None:
        parser.error(helper())
    nodeid = options.i
    if options.b is None:
        parser.error(helper())
    server = options.b

    serverStrip(server)

    cfg = ConfigParser.RawConfigParser()
    cfg.read('key.cfg')      
    key=dict(cfg.items("Keys"))
    for x in key:
        key[x]=key[x].split("#",1)[0].strip() 
    globals().update(key)  

    accessKey = accesskey
    secretKey = secretkey
    headerValue = {}

    nodeId = '/api/node/' + nodeid

    bassUrl = "http://" + server
    r = Api.REST(secretKey=secretKey, accessKey=accessKey, url=serverUrl)
    serverCheck(serverName, nodeId, headerValue, r, serverPort)
示例#17
0
def main(myArgs):
    parser = OptionParser()
    parser.add_option("-b", help="server ip address")
    parser.add_option("-i", help="node id")
    (options, args) = parser.parse_args()
    if options.i is None:
        parser.error(helper())
    nodeid = options.i
    if options.b is None:
        parser.error(helper())
    server = options.b

    serverStrip(server)

    cfg = ConfigParser.RawConfigParser()
    cfg.read('key.cfg')
    key = dict(cfg.items("Keys"))
    for x in key:
        key[x] = key[x].split("#", 1)[0].strip()
    globals().update(key)

    nodeId = nodeid
    accessKey = accesskey
    secretKey = secretkey

    serverUrl2 = "/api/node/" + nodeId + "/usage"

    headerValue = {}
    headerValue["Accept"] = 'application/json'
    headerValue["Content-Type"] = 'application/json'

    r = Api.REST(secretKey=secretKey, accessKey=accessKey, url=serverUrl)

    serverCheck(serverName, headerValue, r, serverPort, serverUrl2)
示例#18
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.api = Api.ApiOS()
        self.baseManager = bm.BaseManager()
        self.scannerManager = sm.ScannerManager()

        self.pathBase = self.baseManager.loadSettings()
        if (self.pathBase is None):
            self.pathBase = ""
        self.ui.tbBasePath.setText(self.pathBase)

        #self.ui.btnRun.clicked.connect(lambda: self.startScan())

        # Обработчик сигнала
        self.signalCount.connect(self.signalCountHandler, Qt.QueuedConnection)
        self.signalFindVirus.connect(self.signalFindVirusHandler,
                                     Qt.QueuedConnection)
        self.signalScanFolder.connect(self.signalScanFolderHandler,
                                      Qt.QueuedConnection)
        self.signalScanFile.connect(self.signalScanFileHandler,
                                    Qt.QueuedConnection)
        self.signalCommit.connect(self.signalCommitHandler,
                                  Qt.QueuedConnection)
示例#19
0
 def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)
     self.configure(bg=FL_BG_COLOR)
     label = tk.Label(self, text="Films", font=FL_TITLE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
     label.grid(row=1, columnspan=1, column=0, sticky=tk.W, padx=25)
     uitleg = tk.Label(
         self,
         text="Klik op een plaatje voor informatie over de film of om een kaartje te kopen.",
         font=FL_BASE_FONT,
         bg=FL_BG_COLOR,
         fg=FL_TEXT_COLOR,
     )
     uitleg.grid(row=2, sticky=tk.W, padx=25, pady=25)
     button = tk.Button(
         self,
         text="Logout",
         command=lambda: self.Login(controller),
         font=FL_BASE_FONT,
         bg=FL_BG_COLOR,
         fg=FL_TEXT_COLOR,
         relief="flat",
     )
     button.grid(row=0, column=1, ipadx=820)
     apis = Api()
     movie_list = apis.getMovieList(apis.getCurrentTime())
     for titel in movie_list:
         images = tk.PhotoImage(str(titel["image"]))
         b1 = tk.Button(
             self, command=lambda titel=titel: self.details(controller, titel), image=images, height=125, width=100
         )
         b1.grid(pady=10)
         # save the button image from garbage collection!
         b1.image = images
         tijd = datetime.datetime.fromtimestamp(int(titel["starttijd"]))
         titelbtn = tk.Button(
             self,
             command=lambda titel=titel: self.details(controller, titel),
             text=titel["title"],
             font=("Helvetica", 10, "bold"),
             bg=FL_BG_COLOR,
             fg=FL_TEXT_COLOR,
             relief="flat",
         )
         titelbtn.grid()
         starttijd = tk.Label(self, text=str(tijd), font=FL_BASE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
         starttijd.grid()
示例#20
0
 def __init__(self):
     self.config = Helper.Config()
     self.api = Api.PublicApi()
     self.tapi = Tapi.TradeApi()
     self.buyslipage = self.config.buySlipage
     self.sellslipage = self.config.sellSlipage
     self.tickerfrequency = self.config.bigtickerfreq
     self.currentfunds = self.getCurrentAccountState()
     self.currentticker = None
示例#21
0
def check_connection():
    try:
        resp = Api.version()
    except Exception as e:
        Log.Info(e)
        return False, str(e)
    if "Error" in resp:
        return False, resp['Error']
    return True, "oke"
示例#22
0
def check_connection():
    try:
        resp = Api.version()
    except Exception as e:
        Log.Info(e)
        return False , str(e)
    if "Error" in resp:
        return False , resp['Error']
    return True , "oke"
示例#23
0
 def requestChatInfo(self, chat_id):
     if chat_id not in self.data:
         self.data[chat_id] = {'id': chat_id, 'log': []}
     data = Api.request('messages.getChat', {'chat_id': chat_id})
     if data == None:
         return
     if len(data['users']) > 0:
         Users.requestUsers([str(u) for u in data['users']])
     self.data[chat_id]['data'] = data
示例#24
0
def runMainApp():
    #set up the config
    conf = {
        '/': {
            'tools.staticdir.root': os.getcwd(),
            'tools.encode.on': True,
            'tools.encode.encoding': 'utf-8',
            'tools.sessions.on': True,
            'tools.sessions.timeout':
            60 * 1,  #timeout is in minutes, * 60 to get hours

            # The default session backend is in RAM. Other options are 'file',
            # 'postgres', 'memcached'. For example, uncomment:
            # 'tools.sessions.storage_type': 'file',
            # 'tools.sessions.storage_path': '/tmp/mysessions',
        },

        #configuration for the static assets directory
        '/static': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': 'static',
        },

        #once a favicon is set up, the following code could be used to select it for cherrypy
        #'/favicon.ico': {
        #    'tools.staticfile.on': True,
        #    'tools.staticfile.filename': os.getcwd() + '/static/favicon.ico',
        #},
    }

    cherrypy.site = {'base_path': os.getcwd()}

    # Create an instance of MainApp and tell Cherrypy to send all requests under / to it. (ie all of them)
    cherrypy.tree.mount(server.MainApp(), "/", conf)
    cherrypy.tree.mount(Api.ApiApp(), "/api/", conf)

    # Tell cherrypy where to listen, and to turn autoreload on
    cherrypy.config.update({
        'server.socket_host': LISTEN_IP,
        'server.socket_port': LISTEN_PORT,
        'engine.autoreload.on': True,
    })

    #cherrypy.tools.auth = cherrypy.Tool('before_handler', auth.check_auth, 99)

    print("========================================")
    print("             Hammond Pearce")
    print("         University of Auckland")
    print("   COMPSYS302 - Example client web app")
    print("========================================")

    # Start the web server
    cherrypy.engine.start()

    # And stop doing anything else. Let the web server take over.
    cherrypy.engine.block()
示例#25
0
 def setData(self, data):
     apis = Api()
     database = DataBase()
     self.data = data
     gastenlijst = database.getGastLijst(data['titel'], apis.getCurrentTime())
     if not gastenlijst:
         for cc in range(1, 4):
             geengasten = tk.Label(self, text='Geen gasten', font=FL_BASE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
             geengasten.grid(row=3, column=cc)
     else:
         for titels in gastenlijst:
             gasttitel = tk.Label(self, text=titels['film'], font=FL_BASE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
             gasttitel.grid(row=3, column=1)
         for namen in gastenlijst:
             naam_gast = tk.Label(self, text=namen['naam'], font=FL_BASE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
             naam_gast.grid(row=3, column=2)
         for mails in gastenlijst:
             mail_gast = tk.Label(self, text=mails['email'], font=FL_BASE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
             mail_gast.grid(row=3, column=3)
示例#26
0
def servers():
    result = []
    servers = Api.getServers()
    for server in servers:
        result.append({
            'alias':    server['alias'],
            'hostname': server['hostname'],
            'branch':   server['branch']
        })
    return json.dumps(result)
示例#27
0
 def requestChatInfo(self, chat_id):
     if chat_id not in self.data:
         self.data[chat_id] = {
             'id':  chat_id,
             'log': []
         }
     data = Api.request('messages.getChat', {'chat_id': chat_id})
     if data == None:
         return
     if len(data['users']) > 0:
         Users.requestUsers([ str(u) for u in data['users'] ])
     self.data[chat_id]['data'] = data
示例#28
0
		def downloadTickerAllPairs():
			"""
			Stáhne tickery pro všechny páry z btc-e. K tomu využívá
			modul api.py.
			:return list:
			"""
			# Implementovat obchodování s jen některými páry.
			pairs = self.pairsFromDatabase()
			allstring = "-".join(pairs)
			get = Api.PublicApi()
			allpairsticker = get.getPublicParam("ticker", allstring)
			return allpairsticker
示例#29
0
 def setData(self, data):
     api = Api()
     db = DataBase()
     images = ImageTk.PhotoImage(Image.open(str(data["image"])))
     self.foto.configure(image = images)
     self.foto.image = images
     if db.checkFilmBijAanbieder(data['titel'], api.getCurrentTime()):
         self.aanbieder.configure(text="Gasten lijst",
                                  command=lambda controller=self.controller, data=data: self.gastenlijst(controller, data))
     elif db.checkFilmAanbieder(data['titel'], api.getCurrentTime()):
         self.aanbieder.configure(text="Gereserveerd", command="")
     else:
         self.aanbieder.configure(text="Aanbieden", command=lambda: self.aanbieden(data))
     data = api.getMovieDescription(data["titel"], api.getCurrentTime())
     self.titel['text'] = data['titel']
     self.beschrijving["text"] = data["synopsis"]
     self.jaar["text"] = data["jaar"]
     self.cast["text"] = data["cast"]
     self.genre["text"] = data["genre"]
     self.duur["text"] = data["duur"]
     self.zender["text"] = data["zender"]
示例#30
0
 def requestUsers(self, user_ids):
     c.log('debug', 'Requesting users (%i)' % len(user_ids))
     while len(user_ids) > 0:
         data = Api.request('users.get', {'user_ids': ','.join(user_ids[0:1000]), 'fields': ''})
         if data == None:
             return
         del user_ids[0:1000]
         for user in data:
             c.log('debug', '  %i %s %s' % (user['id'], user['first_name'], user['last_name']))
             self.addUser(user)
         if len(user_ids) > 0:
             c.log('debug', '  left %i' % len(user_ids))
示例#31
0
    def requestComments(self, data, data_type, owner_id):
        if str(owner_id) != Api.getUserId():
            return

        c.log('debug', 'Requesting comments for %s %i' % (data_type, data['id']))

        if data_type == 'photo':
            api_method = 'photos.getComments'
            api_id_name = 'photo_id'
        elif data_type == 'video':
            api_method = 'video.getComments'
            api_id_name = 'video_id'
        elif data_type == 'wall':
            api_method = 'wall.getComments'
            api_id_name = 'post_id'
        else:
            c.log('warning', 'Unable to request comments for %s %i - not implemented' % (data_type, data['id']))
            return

        if 'comments' not in data:
            data['comments'] = {}
        if not isinstance(data['comments'], dict):
            data['comments'] = {}

        req_data = {'owner_id': int(owner_id), api_id_name: int(data['id']), 'count': 100, 'offset': 0}

        while True:
            subdata = Api.request(api_method, req_data)
            if subdata == None:
                return
            count = subdata['count']
            subdata = subdata['items']
            for d in subdata:
                data['comments'][str(d['date'])] = d
                self.loadAttachments(data['comments'][str(d['date'])])

            req_data['offset'] += 100
            if req_data['offset'] >= count:
                break
示例#32
0
def main():
    tier_list = ['IRON', 'BRONZE', 'SILVER', 'GOLD', 'PLATINUM', 'DIAMOND']
    division_list = ['IV', 'III', 'II', 'I']
    summonerids = []

    for i in tier_list:
        for j in division_list:
            data = api.get_summoners(i, j)
            for x in data:
                summonerids.append(x['summonerId'])
            time.sleep(1)

    print(summonerids)
示例#33
0
 def setData(self, data):
     apis = Api()
     database = DataBase()
     self.data = data
     gastenlijst = database.getGastLijst(data['titel'],
                                         apis.getCurrentTime())
     if not gastenlijst:
         for cc in range(1, 4):
             geengasten = tk.Label(self,
                                   text='Geen gasten',
                                   font=FL_BASE_FONT,
                                   bg=FL_BG_COLOR,
                                   fg=FL_TEXT_COLOR)
             geengasten.grid(row=3, column=cc)
     else:
         for titels in gastenlijst:
             gasttitel = tk.Label(self,
                                  text=titels['film'],
                                  font=FL_BASE_FONT,
                                  bg=FL_BG_COLOR,
                                  fg=FL_TEXT_COLOR)
             gasttitel.grid(row=3, column=1)
         for namen in gastenlijst:
             naam_gast = tk.Label(self,
                                  text=namen['naam'],
                                  font=FL_BASE_FONT,
                                  bg=FL_BG_COLOR,
                                  fg=FL_TEXT_COLOR)
             naam_gast.grid(row=3, column=2)
         for mails in gastenlijst:
             mail_gast = tk.Label(self,
                                  text=mails['email'],
                                  font=FL_BASE_FONT,
                                  bg=FL_BG_COLOR,
                                  fg=FL_TEXT_COLOR)
             mail_gast.grid(row=3, column=3)
示例#34
0
 def requestUsers(self, user_ids):
     c.log('debug', 'Requesting users (%i)' % len(user_ids))
     while len(user_ids) > 0:
         data = Api.request('users.get', {
             'user_ids': ','.join(user_ids[0:1000]),
             'fields': ''
         })
         if data == None:
             return
         del user_ids[0:1000]
         for user in data:
             c.log(
                 'debug', '  %i %s %s' %
                 (user['id'], user['first_name'], user['last_name']))
             self.addUser(user)
         if len(user_ids) > 0:
             c.log('debug', '  left %i' % len(user_ids))
示例#35
0
def getDefaultApiList(self):
    apiKey = self.globals.getApiSetting('api.basic.api.key')
    if (self.repository.existsByKeyAndCommit(apiKey, Api)):
        return [self.repository.findByKeyAndCommit(apiKey, Api)]
    else:
        projectName = self.globals.getApiSetting('api.basic.api.project-name')
        apiClassName = self.globals.getApiSetting('api.basic.api.class-name')
        gitUrl = self.globals.getApiSetting('api.git.url')
        gitExtension = self.globals.getApiSetting('api.git.extension')
        importScript = ADD_APPLICATION_FILE_SCRIPT.replace(
            APPLICATION_TOKEN, apiClassName)
        sessionList = []
        return [
            Api(apiKey, projectName, apiClassName,
                f'''{gitUrl}/{apiClassName}.{gitExtension}''', importScript,
                sessionList)
        ]
示例#36
0
def AddData(device, value):
    DATA.append({
        "percentageoflight":
        value,
        "creationdatetime":
        "{0:%Y-%m-%d %H:%M:%S.%f}".format(datetime.datetime.now())
    })

    if len(DATA) > 1000:
        print("Sending Data")

        lightSensor = [x for x in device["sensors"] if x["name"] == "Light"][0]
        response = Api.PostData(device["device"]["id"], lightSensor["id"],
                                DATA)
        print("Data Sent")

        if response:
            DATA.clear()
示例#37
0
    def requestFriends(self, user_id):
        c.log('info', 'Requesting friends')
        if user_id not in self.data:
            self.data[user_id] = {'id': user_id}

        data = Api.request('friends.get', {'user_id': user_id})
        if data == None:
            return
        friends = [ str(f) for f in data['items'] ]

        if 'friends' not in self.data[user_id]:
            self.data[user_id]['friends'] = { long(time.time()): friends[:] }
        else:
            user_friends = self.data[user_id]['friends']
            if len(set(user_friends[max(user_friends)]) & set(friends)) != len(friends):
                user_friends[long(time.time())] = friends[:]

        return friends
示例#38
0
    def requestBlog(self, user_id):
        c.log('info', 'Requesting user blog')
        if 'blog' not in self.data[user_id]:
            self.data[user_id]['blog'] = {}
        req_data = {'owner_id': user_id, 'count': 100, 'offset': 0}

        while True:
            data = Api.request('wall.get', req_data)
            if data == None:
                return
            count = data['count']
            data = data['items']
            for d in data:
                self.data[user_id]['blog'][str(d['date'])] = d
                Media.processWall(self.data[user_id]['blog'][str(d['date'])])

            req_data['offset'] += 100
            if req_data['offset'] >= count:
                break
示例#39
0
    def requestFriends(self, user_id):
        c.log('info', 'Requesting friends')
        if user_id not in self.data:
            self.data[user_id] = {'id': user_id}

        data = Api.request('friends.get', {'user_id': user_id})
        if data == None:
            return
        friends = [str(f) for f in data['items']]

        if 'friends' not in self.data[user_id]:
            self.data[user_id]['friends'] = {long(time.time()): friends[:]}
        else:
            user_friends = self.data[user_id]['friends']
            if len(set(user_friends[max(user_friends)])
                   & set(friends)) != len(friends):
                user_friends[long(time.time())] = friends[:]

        return friends
示例#40
0
    def requestUserPhotos(self, user_id):
        c.log('info', 'Requesting user photos')
        if 'user_photos' not in self.data[user_id]:
            self.data[user_id]['user_photos'] = {}
        req_data = {'user_id': user_id, 'count': 1000, 'offset': 0}

        while True:
            data = Api.request('photos.getUserPhotos', req_data)
            if data == None:
                return
            count = data['count']
            data = data['items']
            for d in data:
                self.data[user_id]['user_photos'][str(d['date'])] = d
                Media.processPhoto(self.data[user_id]['user_photos'][str(d['date'])])

            req_data['offset'] += 1000
            if req_data['offset'] >= count:
                break
示例#41
0
    def addUser(self, newdata):
        # Add new data to user id if latest is different
        newdata_id = str(newdata.pop('id'))
        if newdata_id not in self.data:
            c.log('debug', 'Adding new user %s' % newdata_id)
            self.data[newdata_id] = {
                'id': newdata_id,
                'data': { long(time.time()): newdata },
            }
        else:
            if self.data[newdata_id]['updated'] > Api.getStartTime():
                return
            user_data = self.data[newdata_id]['data']
            if len(set(user_data[max(user_data)].items()) & set(newdata.items())) != len(newdata):
                c.log('debug', 'Adding new data for user %s' % newdata_id)
                user_data[long(time.time())] = newdata

        self.requestProfilePhotos(newdata_id)
        self.data[newdata_id]['updated'] = long(time.time())
示例#42
0
 def __init__(self):
     # Přiřazení vnějších tříd a metod.
     self.conf = Helper.Config()
     self.tapi = Tapi.TradeApi()
     self.api = Api.PublicApi()
     self.bigticker = None
     self.printer = Printer.TraderPrinter()
     self.logger = Logger.TraderLogging()
     self.methods = TradeMethods()
     self.currentfunds = self.getCurrentAccountState()
     self.initialfunds = self.currentfunds
     self.usdinitialfunds = self.getAccountStateInUSD()
     self.starttime = time.asctime()
     self.boughts = []
     self.buys = 0
     self.sells = 0
     self.losses = 0
     self.profits = 0
     self.currentticker = None
示例#43
0
    def requestBlog(self, user_id):
        c.log('info', 'Requesting user blog')
        if 'blog' not in self.data[user_id]:
            self.data[user_id]['blog'] = {}
        req_data = {'owner_id': user_id, 'count': 100, 'offset': 0}

        while True:
            data = Api.request('wall.get', req_data)
            if data == None:
                return
            count = data['count']
            data = data['items']
            for d in data:
                self.data[user_id]['blog'][str(d['date'])] = d
                Media.processWall(self.data[user_id]['blog'][str(d['date'])])

            req_data['offset'] += 100
            if req_data['offset'] >= count:
                break
示例#44
0
    def requestDialogs(self):
        c.log('debug', 'Requesting dialogs')

        req_data = {'count': 200, 'preview_length': 1, 'offset': 0}

        while True:
            data = Api.request('messages.getDialogs', req_data)
            if data == None:
                return
            count = data['count']
            data = data['items']
            for d in data:
                if 'chat_id' in d['message']:
                    Chats.requestChatMessages(str(d['message']['chat_id']))
                else:
                    self.requestMessages(str(d['message']['user_id']))

            req_data['offset'] += 200
            if req_data['offset'] >= count:
                break
示例#45
0
    def requestUserPhotos(self, user_id):
        c.log('info', 'Requesting user photos')
        if 'user_photos' not in self.data[user_id]:
            self.data[user_id]['user_photos'] = {}
        req_data = {'user_id': user_id, 'count': 1000, 'offset': 0}

        while True:
            data = Api.request('photos.getUserPhotos', req_data)
            if data == None:
                return
            count = data['count']
            data = data['items']
            for d in data:
                self.data[user_id]['user_photos'][str(d['date'])] = d
                Media.processPhoto(self.data[user_id]['user_photos'][str(
                    d['date'])])

            req_data['offset'] += 1000
            if req_data['offset'] >= count:
                break
示例#46
0
    def setData(self, data):
        apis = Api()
        db = DataBase()
        movie_list = apis.getMovieList(apis.getCurrentTime())
        col = 0
        date = apis.getCurrentTime()
        geenfilm = True
        for titel in movie_list:
            if db.checkFilmAanbieder(titel['titel'], date):
                images = ImageTk.PhotoImage(Image.open(str(titel['image'])))
                b1 = tk.Button(self,
                               command=lambda controller=self.controller, titel=titel: self.details(controller, titel),
                               image=images, height=290,
                               width=168)
                b1.grid(row=3, column=col, pady=25, padx=10)
                # save the button image from garbage collection!
                b1.image = images
                tijd = datetime.datetime.fromtimestamp(int(titel['starttijd']))
                titel['aanbieder'] = db.getFilmAanbieder(titel['titel'], date)
                titelbtn = tk.Button(self,
                                     command=lambda controller=self.controller, titel=titel: self.details(controller,
                                                                                                          titel),
                                     text=titel['titel'],
                                     font=("Tahoma", 10, "bold"), bg=FL_BG_COLOR, fg=FL_TEXT_COLOR, relief="flat",
                                     activebackground=FL_BG_COLOR, activeforeground=FL_TEXT_COLOR)
                titelbtn.grid(row=4, column=col)
                starttijd = tk.Label(self, text=str(tijd), font=FL_BASE_FONT, bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
                starttijd.grid(row=5, column=col)
                aanbieders = tk.Label(self, text=titel['aanbieder'], font=FL_BASE_FONT, bg=FL_BG_COLOR,
                                      fg=FL_TEXT_COLOR)
                aanbieders.grid(row=6, column=col)
                col += 1
                geenfilm = False

        if geenfilm:
            if apis.getError() != '':
                label = tk.Label(self, text=apis.getError(), font=FL_BASE_FONT,
                                 bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
                label.grid(row=3, column=0, sticky='w', padx=25, columnspan=5)
            elif db.getError() != '':
                label = tk.Label(self, text=db.getError(), font=FL_BASE_FONT,
                                 bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
                label.grid(row=3, column=0, sticky='w', padx=25, columnspan=5)
            else:
                label = tk.Label(self, text="Er zijn geen aanbieders die een film aanbieden", font=FL_BASE_FONT,
                                 bg=FL_BG_COLOR, fg=FL_TEXT_COLOR)
                label.grid(row=3, column=0, sticky='w', padx=25, columnspan=5)
示例#47
0
    def __init__(self):
        self.stores_list = ["Carrefour", "Carrefour Market", "Carrefour Planet",
                            "Carrefour Express", "Carrefour GB", "Colruyt", "Spa",
                            "Delhaize", "Delhaize City", "Proxy Delhaize", "AD Delhaize",
                            "Shop\\'n Go", "Albert Heijn", "Intermarché", "Cora", "Match",
                            "Smatch", "Louis Delhaize", "Aldi", "Lidl", "Magasins U",
                            "Super U", "Hyper U", "Auchan", "Noz", "Casino", "Leclerc",
                            "Géant", "Dia", "Edeka", "magasins diététiques"]
        self.category_list = ["Produits laitiers", "Boissons", "Petit-déjeuners",
                              "Viandes", "Desserts"]
        self.sub_category_list = [
            ["Laits", "Beurres", "Boissons lactées", "Fromages"],
            ["Sodas", "Boissons au thé", "Boissons énergisantes"],
            ["Céréales pour petit-déjeuner", "Pâtes à tartiner", "Confitures et marmelades"],
            ["Charcuteries", "Volailles"],
            ["Desserts au chocolat", "Compotes", "Desserts lactés", "Snacks sucrés"]
            ]

        self.config = None # is going to be initialize in method 'import_json_data()'
        self.database = None # is going to be initialize in method 'connection()'
        self.dict_of_stores = None # is going to be initialize in method 'retrieve_store_dict()'
        self.openfoodfact = A.Api()
示例#48
0
def requestMessages(request, msgs_data):
    request['count'] = 200
    request['offset'] = -200
    if len(msgs_data['log']) == 0:
        request['rev'] = 1
        request['offset'] = 0
    else:
        request['start_message_id'] = msgs_data['log'][-1]['id']

    while True:
        data = Api.request('messages.getHistory', request)
        if data == None:
            return
        count = data['count']
        data = data['items']

        if len(data) == 0:
            c.log('info',
                  '  no new messages %i (%i)' % (len(msgs_data['log']), count))
            break

        # Switch to get history by message id
        if 'start_message_id' not in request:
            request['offset'] = -200
            request.pop('rev', None)
        else:
            data.reverse()

        processMessages(data)
        msgs_data['log'].extend(data)

        request['start_message_id'] = data[-1]['id']
        c.log(
            'info', '  loaded %i, stored %i (%i)' %
            (len(data), len(msgs_data['log']), count))
        if len(data) < 200:
            c.log('info', '  done')
            break
示例#49
0
    def addUser(self, newdata):
        # Add new data to user id if latest is different
        newdata_id = str(newdata.pop('id'))
        if newdata_id not in self.data:
            c.log('debug', 'Adding new user %s' % newdata_id)
            self.data[newdata_id] = {
                'id': newdata_id,
                'data': {
                    long(time.time()): newdata
                },
            }
        else:
            if self.data[newdata_id]['updated'] > Api.getStartTime():
                return
            user_data = self.data[newdata_id]['data']
            if len(
                    set(user_data[max(user_data)].items())
                    & set(newdata.items())) != len(newdata):
                c.log('debug', 'Adding new data for user %s' % newdata_id)
                user_data[long(time.time())] = newdata

        self.requestProfilePhotos(newdata_id)
        self.data[newdata_id]['updated'] = long(time.time())
示例#50
0
def add_spotnet_post(post , **kwargs):   
    if post.has_encrypted_nzbsite():
        resp = Api.add_url(get_encrypted_nzbsite() , post.title , **kwargs)
    elif post.has_nzb():
        resp = Api.add_file(post.get_nzb_content() , post.title , **kwargs)
    return resp
示例#51
0
if __name__ == "__main__":

  parser = OptionParser('usage: %prog [options] [SOURCES...]')
  parser.add_option('-a', '--api',    dest = 'api',                      help = 'API name',                    default = 'gl')
  parser.add_option('-i', '--input',  dest = 'input',  metavar = 'FILE', help = 'input file in Khronos XML format', default = '-' )
  parser.add_option('-o', '--output', dest = 'output', metavar = 'FILE', help = 'Python output file',          default = [])
  (options, args) = parser.parse_args()

  # Read input XML
  
  if options.input!='-':
    xmldoc = minidom.parse(options.input)
  else:
    xmldoc = minidom.parse(sys.stdout)

  api = Api()

  # typedefs

  for type in xmldoc.getElementsByTagName('type'):
    n = type.getElementsByTagName('name')
    if len(n):
      name = n[0].firstChild.nodeValue
      str = getText(type.childNodes).strip()
      if str.startswith('typedef '):
        str = str[8:]
      if str.endswith(';'):
        str = str[:-1]
      ee = Typedef(name, str.strip())
      if name == 'GLboolean':
        ee.default = 'GL_FALSE'
示例#52
0
def merge(server, branch):
    result = Api.merge(branch, server, currentUser)
    return json.dumps(result)
示例#53
0
def deploy(server, branch):
    result = Api.deploy(branch, server, currentUser)
    return json.dumps(result)
示例#54
0
def check(server, branch):
    result = Api.check(branch, server, currentUser)
    return json.dumps(result)
示例#55
0
def branches():
    branches = Api.getBranches()
    return json.dumps(branches)
示例#56
0
import Api
from Api import Api
from Api import Function, Typedef, Enum
from Api import Return, Parameter, Input, Output, InputOutput
from Api import Enumerant
from Api import Extension
from Api import StateType, State

cgl = Api()

CGLContextObj = Typedef('CGLContextObj','void *')
CGLContextObj.default = '0'

CGLPixelFormatObj = Typedef('CGLPixelFormatObj','void *')
CGLPixelFormatObj.default = '0'

CGLRendererInfoObj = Typedef('CGLRendererInfoObj','void *')
CGLRendererInfoObj.default = '0'

CGLPBufferObj = Typedef('CGLPBufferObj','void *')
CGLPBufferObj.default = '0'

CGLShareGroupObj = Typedef('CGLShareGroupObj','void *')
CGLShareGroupObj.default = '0'

IOSurfaceRef = Typedef('IOSurfaceRef','struct __IOSurface *')
IOSurfaceRef.default = '0'

CGSConnectionID = Typedef('CGSConnectionID','void *')

CGSWindowID = Typedef('CGSWindowID','long long')
示例#57
0
文件: egl.py 项目: Mars999/regal
import Api
from Api import Api
from Api import Function, Typedef, Enum
from Api import Return, Parameter, Input, Output, InputOutput
from Api import Enumerant

egl = Api()
EGLNativeWindowType = Typedef('EGLNativeWindowType','struct ANativeWindow*')
EGLNativeWindowType.default = '0'

EGLNativePixmapType = Typedef('EGLNativePixmapType','struct egl_native_pixmap_t*')
EGLNativePixmapType.default = '0'

EGLNativeDisplayType = Typedef('EGLNativeDisplayType','void*')
EGLNativeDisplayType.default = '0'

NativeDisplayType = Typedef('NativeDisplayType','EGLNativeDisplayType')
NativeDisplayType.default = '0'

NativePixmapType = Typedef('NativePixmapType','EGLNativePixmapType ')
NativePixmapType.default = '0'

NativeWindowType = Typedef('NativeWindowType','EGLNativeWindowType ')
NativeWindowType.default = '0'

EGLint = Typedef('EGLint','int')
EGLint.default = '0'

EGLBoolean = Typedef('EGLBoolean','unsigned int')
EGLBoolean.default = '0'
示例#58
0
文件: win32.py 项目: nigels-com/regal
import Api
from Api import Api
from Api import Function, Typedef, Enum
from Api import Return, Parameter, Input, Output, InputOutput
from Api import Enumerant
from Api import Extension
from Api import StateType, State

win32 = Api()

VOID = Typedef('VOID','void')

PVOID = Typedef('PVOID','void *')
PVOID.default = '0'

HANDLE = Typedef('HANDLE','PVOID')
HANDLE.default = '0'

LPCSTR = Typedef('LPCSTR','const char *')
LPCSTR.default = '0'

INT32 = Typedef('INT32','signed int')
INT32.default = '0'

INT64 = Typedef('INT64','signed __int64')
INT64.default = '0'

LPVOID = Typedef('LPVOID','void *')
LPVOID.default = '0'

BOOL = Typedef('BOOL','int')
示例#59
0
import os
import sys
apiCreatePath = os.path.dirname(os.path.realpath(__file__))

from Api import *

if len(sys.argv) != 2:
  print sys.argv
  print "Invalid # of args - expecting: (gameCode)"
  exit()

gameCode = sys.argv[1]

api = Api(gameCode)
api.createGame()
print json.dumps(api.getGame())
示例#60
0
 def aanbieden(self, data):
     api = Api()
     db = DataBase()
     if db.saveAanbieder(data['titel'], api.getCurrentTime()):
         self.aanbieder.configure(text="Gasten lijst",
                                  command=lambda controller=self.controller: self.gastenlijst(controller, data))