Пример #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 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)
Пример #3
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
Пример #4
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)
Пример #5
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"]
Пример #6
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)
        ]
Пример #7
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()
Пример #8
0
    def init(self):
        """Initialisation"""
        categories = ['aperitif', 'biscuits', 'boissons', 'confiseries',\
         'produits-a-tartiner-sucres']
        self.db = Database.Database()
        if not self.db.does_database_exists():
            self.db.create_database()
            self.db.connect()
            self.db.create_tables()

            api_data = []
            for current_category in range(len(categories)):
                api_data.append(Api.Api(categories[current_category]))
                api_data[current_category].get_data()
                for current_product in range(
                        len(api_data[current_category].name)):
                    self.db.save_product(api_data[current_category].name[current_product],\
                     api_data[current_category].category,\
                     api_data[current_category].nutri_score[current_product],\
                      api_data[current_category].url[current_product],\
                       api_data[current_category].stores[current_product])
            self.db.disconnect()
        self.db.connect()
Пример #9
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)
Пример #10
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"]
Пример #11
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

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','void *')
IOSurfaceRef.default = '0'

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

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

CGSSurfaceID = Typedef('CGSSurfaceID','void *')
Пример #12
0
	def generateresponse(phonenumber, textmessage, city, timestamp):
		if textmessage is None:
			return
		textmessage1 = textmessage.lower()
		found = False
		delete = None
		# Check if the person exists in the list of people
		for p in range(len(Response.people)):
			if Response.people[p].phone_number == phonenumber:
				if textmessage1 == "clear":
					delete = p
				else:
					found = True
				# current person
				cpeep = Response.people[p]
		if not (delete is None):
			del(Response.people[delete])
		if (not found):
			newp = Person.Person(phonenumber)
			Response.people.append(newp)
			cpeep = newp
		#finds all symptoms in hashes in text
		i = 0
		while i < len(textmessage1):
			if textmessage1[i] == "#":
				newsymp = ""
				j = i + 1
				while j < (len(textmessage1)):
					if (textmessage1[j] == "#"):
						if newsymp != "#":
							l = len(newsymp) - 1
							newsymp = newsymp.lower()
							if not cpeep.symptoms.__contains__(newsymp) and len(newsymp) > 0:
								cpeep.symptoms.append(newsymp)
							i = j
							break
					else:
						newsymp += textmessage1[j]
					j += 1
			i += 1
		if cpeep.gender == "":
			if textmessage1 == "f" or textmessage1 == "m":
				cpeep.gender = textmessage1
			else:
				return ("" if found else "You've reached TextMD. Please provide us with your basic information to help us perform a diagnosis.\n") + "What is your gender? Please enter F for female and M for male."
		if cpeep.gender != "" and cpeep.age == -1:
			try:
				age = int(textmessage1)
				if 0 <= age <= 150 :
					cpeep.age = age
				else:
					return "How old are you?"
			except ValueError:
				return ("How old are you?")
		if cpeep.gender != "" and cpeep.age >= 0:
			if textmessage1[-2:] == "**":
				if len(cpeep.symptoms) == 0:
					return "Please enter at least one symptom."
				keys = []
				error = []
				for symptom in cpeep.symptoms:
					s = Symptoms.Symptoms()
					k = s.getSymptomKey(symptom)
					if k is not None:
						keys.append(s.getSymptomKey(symptom))
					else:
						error.append(symptom)
				a = Api.Api("male" if cpeep.gender == "m" else "female",
						cpeep.age)
				conditions = a.get_conditions(
						"male" if cpeep.gender == "m" else "female",
						cpeep.age, keys)
				if len(conditions) >= 1 and len(error) == 0:
					item = [conditions[0], city, timestamp]
					Response.cases.append(item)
					return "You might have" + ("one of the following (in order of likelyhood):\n" if len(conditions) > 1 else " ") + conditions[0] + ("" if len(conditions) < 2 else (", " + conditions[1])) + ("" if len(conditions) < 3 else (", " + conditions[2])) + "." + "\n" + "Do you require professional help? Reply with '#' if you want a number to call for professional help."
				elif len(conditions) >= 1 and len(error) != 0:
					return "You might have" + ("one of the following (in order of likelyhood):\n" if len(conditions) > 1 else " ") + conditions[0] + ("" if len(conditions) < 2 else (", " + conditions[1])) + ("" if len(conditions) < 3 else (", " + conditions[2])) + "." + "\n" + "Do you require professional help? Reply with '#' if you want a number to call for professional help." + "\n" + "The following symptoms you entered are not in our database: " + str(error) + ". Please reword the symptoms."
				else:
					return "There are no matching conditions for your symptoms. \n" + "The following symptoms you entered are not in our database: " + str(error) + ". Please reword the symptoms."
			elif textmessage1 == "#":
				return "Please call 519-653-7700 for the Waterloo Regional Police Service (non-emergency)."
			else:
				return "Please enter all relevant symptoms in between two hashes (e.g. #headache#).\nType the word \"CLEAR\" to clear your information.\nEnd your message with ** to receive your diagnosis. (DISCLAIMER: This is not to be used as medical advice. For a complete diagnosis, it is advised that you seek professional help.)"
    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'
Пример #14
0
def main():
    trace = True

    # instantiate call to API
    #
    api = Api()

    # load appropriate h5 file corresponding to a instrument and specific day
    #
    instruments = Api.get_instrument_names()
    year, month, day = '2018', '06', '13'
    api.load_h5(instruments[3], year, month, day)

    # get timestamps
    #
    timestamps = api.get_timestamps()
    if trace:
        print(len(timestamps))
        print(timestamps[0], convert_timestamp_to_dtstring(timestamps[0]))
        print(timestamps[-1], convert_timestamp_to_dtstring(timestamps[-1]))

    index = 0
    for timestamp in timestamps:
        print(index, timestamp, convert_timestamp_to_dtstring(timestamp))
        index += 1

    # get order_book
    # get book_balance
    # get weighted_book_balance
    #
    order_book = api.get_order_book(timestamps[5207])
    print(order_book)
    Api.plot_order_book(order_book)
    order_book = api.get_order_book(timestamps[5208])
    print(order_book)
    Api.plot_order_book(order_book)

    # order_book2 = api2.get_order_book(timestamps2[9000])
    # print(order_book2)
    # Api.plot_order_book(order_book2)

    # get trades
    #
    trades = api.get_trades(timestamp=timestamps[5207])
    if trace:
        print(trades)

    # get limit_flows
    #
    order_book_start = api.get_order_book(timestamps[5207])
    order_book_end = api.get_order_book(timestamps[5208])
    trades = api.get_trades(timestamps[5207])

    limit_flows = api.get_limit_flows(timestamp_start=timestamps[5207],
                                      timestamp_end=timestamps[5208])

    # Api.plot_flows(limit_flows)
    if trace:
        print('OrderBookStart', order_book_start)
        print('OrderBookEnd', order_book_end)
        print('Trades', trades)
        print('LimitFlows', limit_flows)
Пример #15
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

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'
Пример #16
0
 def __init__(self, config):
     self.config = config
     self.api = Api.Api(config)
Пример #17
0
import requests
import mysql.connector
from mysql.connector import errorcode
import json
from Api import *
from database import *
from pprint import pprint
import os

if __name__ == '__main__':
    test = Api()
    test.verif_files()
    bdd = Database()

    if test.verif == False:
        test.api_request()
        test.data_processing()
    try:
        bdd.connect()
    except mysql.connector.Error as err:
        if err.errno == errorcode.ER_BAD_DB_ERROR:
            bdd.create_database()

    with open('../database/list.json', 'r') as f:
        datas = json.load(f)
    bdd.database_transfert(datas)
Пример #18
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)
Пример #19
0
def apis(api, command):
    if command == 1:
        api.broker()
    elif command == 2:
        api.devices()
    elif command == 3:
        api.device()
    elif command == 4:
        api.users()
    elif command == 5:
        api.user()
    elif command == 6:
        api.service()
    elif command == 7:
        api.services()
    else:
        print('\nNot a valid command!')


if __name__ == "__main__":

    while True:
        c = menu()
        if c == 0:
            break
        else:
            e = Api.Api()
            apis(e, c)

    print('\nEnd of program')