Exemplo n.º 1
0
 def __init__(self):
     print("SetUp HAS STARTED")
     FUN = fun.FindMedia()
     self.FUN = FUN
     FUNKY = fun.Functions()
     FUNKY.insert_user(os.environ["AMP_USERNAME"],
                       os.environ["AMP_PASSWORD"])
Exemplo n.º 2
0
 def door_encryption(self, ptext, key):
     f = functions.Functions()
     keymatrix = f.string_to_key_matrix(key)
     # calc key matrix
     keymatrix_final = f.keymatrix_calculation(keymatrix)
     if f.inverse_num_calculation(
             f.determinant_calculation(keymatrix_final)) == -1:
         print("\n\nKey Matrix is not invertible!\n")
         print(keymatrix)
         exit(1)
     text_new = ptext
     # in case text length is odd
     if len(ptext) % 2 == 1:
         text_new += 'A'
     slices = [0, 0]
     i = 0
     cipher_text = [0 for x in range(len(text_new))]
     while i < len(text_new):
         slices[0] = f.cvt_char_to_int(text_new[i])
         slices[1] = f.cvt_char_to_int(text_new[i + 1])
         vec = f.vec_mat_mul_calculation(slices, keymatrix_final)
         cipher_text[i] = f.cvt_int_to_char(vec[0])
         cipher_text[i + 1] = f.cvt_int_to_char(vec[1])
         i += 2
     return keymatrix_final, cipher_text
Exemplo n.º 3
0
 def populate(self, box, schema_name):
     for child in box.get_children():
         box.remove(child)
     functions.Functions(self.main, self.conn, box, schema_name,
                         self.schema_store)
     sequences.Sequences(self.main, self.conn, box, schema_name)
     tables.Tables(self.main, self.conn, box, schema_name,
                   self.schema_store)
     views.Views(self.main, self.conn, box, schema_name, self.schema_store)
Exemplo n.º 4
0
def test_checking_weight_of_connections_between_functions():
    data_list = ['python_files.py']
    function_of_python_files_py = ['list_directory']
    result_exp = ['list_directory']
    Class_object = functions.Functions(
    )  #createing object of this specific class

    result = functions.Functions.checking_weight_of_connections_between_functions(
        Class_object, data_list, function_of_python_files_py)

    assert result == result_exp
def upload_template_python_scripts():
    s3_client = boto3.client('s3', region_name=REGION)
    try:
        s3_client.create_bucket(Bucket=DATA_BUCKET, CreateBucketConfiguration={'LocationConstraint': REGION})
    except ClientError as ce:
        if ce.response['Error']['Code'] == 'BucketAlreadyOwnedByYou':
            print("Data Bucket Already Created")
        else:
            print(ce)
    functions_obj = functions.Functions(REGION)
    functions_obj.upload_object(DATA_BUCKET, "template.yaml", "template.yaml")
    functions_obj.upload_zip_object(DATA_BUCKET, "lambda_function.py", "lambda_function.zip", "lambda_function.zip")
Exemplo n.º 6
0
    def zero_arg_urls(self):
        """If path, less '.html' is a valid function name, 

then check functions.Functions; if found there, run it as a function.
        """
        F = functions.Functions()
        fn_name = self.path.lstrip('/').split('/')[0].split('.')[0]
        if (fn_name[0] in string.ascii_letters and any(
            [i in string.ascii_letters + string.digits + '_' for i in fn_name])
                and fn_name in F.funcs):
            content = eval('F.' + fn_name + '()')
            with open(self.files + fn_name + '.html', 'w') as f:
                f.write(content)
Exemplo n.º 7
0
    def click_load(self):
        global sound
        global load
        entered_text=name_entry.get()

        if os.path.exists(path+str(entered_text)+".wav"):
            sound=f.Functions(path+str(entered_text)+".wav")
            load=True
            output.delete(0.0,END)
            output.insert(END,"Udało się wczytać plik "+str(entered_text)+
            ".\nMożna przeprowadzić wybraną powyżej funkcję")
            self.visual()
        else:
            output.delete(0.0,END)
            output.insert(END,"Podany plik nie istnieje!\n")
Exemplo n.º 8
0
def main():
    OKBLUE = '\033[94m'
    FAIL = '\033[91m'
    OKCYAN = '\033[96m'
    ENDC = '\033[0m'

    parser = argparse.ArgumentParser(description='check urls.')

    parser.add_argument(
        'amount',
        metavar='amount',
        type=int,
        help='an integer for the amount of domains to be checked')

    parser.add_argument('request',
                        metavar='request',
                        type=str,
                        help='a string that that says http:// or https://')

    parser.add_argument(
        'topleveldomain',
        metavar='topleveldomain',
        type=str,
        help='a string that that indicates the toplevelodomain: .com / .us ...'
    )

    args = parser.parse_args()
    amount = args.amount
    request = args.request
    topleveldomain = args.topleveldomain

    fun = functions.Functions()

    if fun.validateArgs(amount, request, topleveldomain) == False:
        r = request
        t = topleveldomain
        a = amount
        for i in range(1, a + 1, 1):
            print(f'{OKBLUE}{i}')
            url = fun.generateUrl(r, t)
            try:
                request = fun.requestContent(url)
                parser = fun.parseContent(request)
                fun.writeToFile(parser)
                print(f'{OKCYAN}{url[0]}')
            except:
                print(f'{FAIL}{url[0]}')
        print(f'{ENDC}finished checking {a} domains.')
Exemplo n.º 9
0
 def door_decryption(self, ctext, key):
     f = functions.Functions()
     keymatrix = f.string_to_key_matrix(key)
     #
     keymatrix_tmp = f.keymatrix_calculation(keymatrix)
     keymatrix_final = f.inverse_mat_calculation(keymatrix_tmp)
     #
     slices = [0, 0]
     i = 0
     decipher_text = [0 for x in range(len(ctext))]
     while i < len(ctext):
         slices[0] = f.cvt_char_to_int(ctext[i])
         slices[1] = f.cvt_char_to_int(ctext[i+1])
         vec = f.vec_mat_mul_calculation(slices, keymatrix_final)
         decipher_text[i] = f.cvt_int_to_char(vec[0])
         decipher_text[i+1] = f.cvt_int_to_char(vec[1])
         i += 2
     return keymatrix_final, decipher_text
Exemplo n.º 10
0
    def __init__(self, widjet, path, lang, report=None):
        super(Convertor, self).__init__()

        self.run_trigger.connect(self.run)
        self.stop_trigger.connect(self.stop)

        self.widjet = widjet
        self.functions = functions.Functions(DEBUG)
        self.curdir = os.path.abspath(os.curdir) + "/libraries/"
        self.path_to_csv = [
            self.curdir + "codes.csv", self.curdir + "RUcodes.csv"
        ]
        self.srFile = ""
        self.lang = lang  #True - RU, False - ENG
        self.report = report
        self.is_stopped = False
        self.plotter = None
        self.path = path + "/output/"
Exemplo n.º 11
0
def upload_template_python_job_scripts():
    s3_client = boto3.client('s3', region_name=REGION)
    try:
        s3_client.create_bucket(
            Bucket=DATA_BUCKET,
            CreateBucketConfiguration={'LocationConstraint': REGION})
    except ClientError as ce:
        if ce.response['Error']['Code'] == 'BucketAlreadyOwnedByYou':
            print("Data Bucket Already Created")
        else:
            print(ce)
    functions_obj = functions.Functions(REGION)
    functions_obj.upload_file_folder(DATA_BUCKET, "Template")
    functions_obj.upload_zip_folder("lambda_job_run_sqs/",
                                    "lambda_job_run_sqs", DATA_BUCKET)
    functions_obj.upload_zip_folder("lambda_crawler_run_ses/",
                                    "lambda_crawler_run_ses", DATA_BUCKET)
    functions_obj.upload_object(DATA_BUCKET, 'csv_job.py',
                                'job_scripts/csv_job.py')
Exemplo n.º 12
0
def main():
    siTcp = functions.Functions()
    # siTcp.ResetDAQ()
    # print('DAQ Reseted! Wait 5 Seconds until ReConnection')
    # time.sleep(5)
    # siTcp = functions.Functions()
    siTcp.InitALPIDE()
    siTcp.alpideregtest()
    siTcp.ReadReg(0x1)
    siTcp.ReadReg(0x4)
    siTcp.ReadReg(0x5)
    siTcp.StartPLL()
    filepath = siTcp.DigitalPulse()
    time.sleep(1)
    filepath = siTcp.InternalTrigger()
    # filepath = siTcp.DigitalPulse()
    # filepath = siTcp.ExternalTrigger()
    # filepath = siTcp.AnaloguePulse(30)
    # DrawPic(filepath)
    siTcp.CloseSock()
Exemplo n.º 13
0
def main():
    # OBJECT CREATION OF CLASSES
    functions_class_object = functions.Functions(parameter)
    stack_class_object = stacks.Stack(parameter)
    tags_class_object = tags.Tags(parameter)

    # INITIAL BUCKET CREATION FOR YAML FILE UPLOADING
    try:
        s3.create_bucket(Bucket=parameter["InitBucketName"],
                         CreateBucketConfiguration={
                             'LocationConstraint': parameter["BucketConfig"]
                         })
    except ClientError:
        print("Data Bucket Already Created")

    # UPLOADING OF YAML FILE OBJECT
    functions_class_object.upload_object()

    # STACK CREATION , UPDATION OR DELETION AS PER REQUIREMENT
    stack_class_object.stack_handler()

    # UPLOADING OF OBJECTS USING FOLDER
    functions_class_object.upload_objects()

    # Tag Creation
    tagset1 = tags.make_tags({'notdivby2': '2no', 'key1': 'val1'})
    #print(tagset1)
    tagset2 = tags.make_tags({'divby2': '2yes', 'key1': 'val1'})
    #print(tagset1)
    # Tag Insertion
    tracker = 1
    while tracker != 11:
        if tracker % 2 == 0:
            obj_name = '{}.txt'.format(tracker)
            tags_class_object.tagging_insertion(obj_name, tagset2)
            print("yo")
        else:
            obj_name = '{}.txt'.format(tracker)
            tags_class_object.tagging_insertion(obj_name, tagset1)
            print("no")
        tracker = tracker + 1
Exemplo n.º 14
0
 def url_is_func(self):
     """Treat stripped path-name as possible function call."""
     # Remove left-most slash.
     path = self.path.lstrip('/')
     # Separate path into its parts.
     fn_name, *args = path.split('/')
     print(fn_name, args)
     if args and '.html' in args[-1]:
         # It is possible the slash denotes a subdirectory, not a function.
         sudirectory_possible = True
     else:
         sudirectory_possible = False
     # Check validity of prospective function name.
     imp.reload(functions)
     F = functions.Functions()
     # If we have html extension on fn_name, remove it.
     fn_name = fn_name.split('.')[0]
     print(fn_name)
     if (fn_name[0] not in string.ascii_letters or
             any([i not in string.ascii_letters + string.digits + '_' for
                 i in fn_name]) or
             fn_name not in F.funcs):
         print('here')
         return
     if not args:
         # Treat zero-argument case together with the case with arguments.
         args = ''
         fn_name = fn_name.split('.')[0]
     # Call the function on any arguments. Report exception in file.
     try:
         content = eval('F.' + fn_name + '(*args)')
     except Exception as e:
         if sudirectory_possible:
             # t was in fact a subdirectory; don't report exception.
             return
         content = 'Exception: ' + str(e)
     # Save to file and ensure that path name is set to that HTML filname.
     with open(self.files + fn_name + '.html', 'w') as f:
         f.write(content)
     self.path = fn_name + '.html'
Exemplo n.º 15
0
    def __init__(self, master):
        super(MainGUI, self).__init__(master)

        # ==== Size of Main Window
        self.master.geometry("800x800")
        self.master.resizable(False, False)

        self.title_font = font.Font(family="Verdana", size=14)
        self.font = font.Font(family="Verdana", size=11)

        # ==== Settings for Title Window
        self.title_window = PanedWindow(self.master, orient="vertical")
        self.title_frame = LabelFrame(self.title_window)
        self.title_window.add(self.title_frame)
        self.title_window.place(x=0, y=0, width=800, height=135)

        self.image_logo = PhotoImage(file="mse_logo.png")
        self.label_logo = Label(self.title_window, image=self.image_logo)
        self.label_logo.place(x=0, y=0)

        # ==== Settings for Spectral Resolution Mode Window  # change 20210603 hojae
        self.res_window = PanedWindow(self.master, orient="vertical")
        self.res_frame = LabelFrame(self.res_window, bg=c0, bd=0)
        self.res_window.add(self.res_frame)
        self.res_window.place(x=0, y=135, width=800, height=100)

        self.res_label = Label(self.res_window,
                               text="Resolution Mode Selection",
                               font=self.title_font,
                               bg=c0,
                               fg=c3)
        self.res_label.place(relx=0.5, rely=0.2, anchor=CENTER)

        self.resolution = StringVar()
        self.resolution.set("LR")

        self.single_radio = Radiobutton(self.res_frame,
                                        text="Low resolution",
                                        variable=self.resolution,
                                        value="LR",
                                        font=self.font,
                                        fg=c3,
                                        bg=c0,
                                        selectcolor=c4)
        self.single_radio.place(relx=0.25, rely=0.6, anchor=CENTER)

        self.single_radio = Radiobutton(self.res_frame,
                                        text="Moderate resolution",
                                        variable=self.resolution,
                                        value="MR",
                                        font=self.font,
                                        fg=c3,
                                        bg=c0,
                                        selectcolor=c4)
        self.single_radio.place(relx=0.5, rely=0.6, anchor=CENTER)

        self.single_radio = Radiobutton(self.res_frame,
                                        text="High resolution",
                                        variable=self.resolution,
                                        value="HR",
                                        font=self.font,
                                        fg=c3,
                                        bg=c0,
                                        selectcolor=c4)
        self.single_radio.place(relx=0.75, rely=0.6, anchor=CENTER)

        # ==== Settings for Calculate Method Window
        self.mode_window = PanedWindow(self.master, orient="vertical")
        self.mode_frame = LabelFrame(self.mode_window, bg=c1, bd=0)
        self.mode_window.add(self.mode_frame)
        self.mode_window.place(x=0, y=235, width=800, height=100)

        self.mode_label = Label(self.mode_window,
                                text="Calculation Mode Selection",
                                font=self.title_font,
                                bg=c1)
        self.mode_label.place(relx=0.5, rely=0.2, anchor=CENTER)

        self.mode = StringVar()
        self.mode.set("S/N Calculation")

        self.single_radio = Radiobutton(self.mode_frame,
                                        text="S/N Calculation",
                                        variable=self.mode,
                                        value="S/N Calculation",
                                        font=self.font,
                                        bg=c1,
                                        command=self.ui_enable)
        self.single_radio.place(relx=0.15, rely=0.6, anchor=CENTER)

        self.single_radio = Radiobutton(
            self.mode_frame,
            text="ExpTime Calculation",
            variable=self.mode,  #add 210408 hojae
            value="ExpTime Calculation",
            font=self.font,
            bg=c1,
            command=self.ui_enable)
        self.single_radio.place(relx=0.37, rely=0.6, anchor=CENTER)

        self.single_radio = Radiobutton(self.mode_frame,
                                        text="S/N vs. Magnitude",
                                        variable=self.mode,
                                        value="S/N vs. Magnitude",
                                        font=self.font,
                                        bg=c1,
                                        command=self.ui_enable)
        self.single_radio.place(relx=0.61, rely=0.6, anchor=CENTER)

        self.single_radio = Radiobutton(self.mode_frame,
                                        text="S/N vs. Wavelength",
                                        variable=self.mode,
                                        value="S/N vs. Wavelength",
                                        font=self.font,
                                        bg=c1,
                                        command=self.ui_enable)
        self.single_radio.place(relx=0.84, rely=0.6, anchor=CENTER)

        # ==== Settings for User Input Parameters Window
        self.input_window = PanedWindow(self.master, orient="vertical")
        self.input_frame = LabelFrame(self.input_window, bg=c2, bd=0)
        self.input_window.add(self.input_frame)
        self.input_window.place(x=0, y=335, width=800, height=400)

        self.input_label = Label(self.input_window,
                                 text="User Input Parameters",
                                 font=self.title_font,
                                 bg=c2)
        self.input_label.place(relx=0.5, rely=0.05, anchor=CENTER)

        # PWV
        self.pwv_label = Label(self.input_frame,
                               text="PWV [mm] = ",
                               font=self.font,
                               bg=c2)
        self.pwv_label.place(x=190, y=40, anchor=E)
        self.pwv_entry = Entry(self.input_frame,
                               width=6,
                               justify=CENTER,
                               textvariable=DoubleVar(value=ini_pwv),
                               font=self.font)
        self.pwv_entry.place(x=190, y=40, anchor=W)

        # Exposure Time
        self.exp_time_label = Label(self.input_frame,
                                    text="Exp. Time [sec] = ",
                                    font=self.font,
                                    bg=c2)
        self.exp_time_label.place(x=190, y=70, anchor=E)
        self.exp_time_entry = Entry(self.input_frame,
                                    width=6,
                                    justify=CENTER,
                                    textvariable=DoubleVar(value=ini_exptime),
                                    font=self.font)
        self.exp_time_entry.place(x=190, y=70, anchor=W)

        # Number of Exposure
        self.exp_num_label = Label(self.input_frame,
                                   text="Number of Exp. = ",
                                   font=self.font,
                                   bg=c2)
        self.exp_num_label.place(x=190, y=100, anchor=E)
        self.exp_num_entry = Entry(self.input_frame,
                                   width=6,
                                   justify=CENTER,
                                   textvariable=DoubleVar(value=ini_expnumber),
                                   font=self.font)
        self.exp_num_entry.place(x=190, y=100, anchor=W)

        # Target S/N #add 210408 hojae
        self.target_sn_label = Label(self.input_frame,
                                     text="Target S/N = ",
                                     font=self.font,
                                     bg=c2)
        self.target_sn_label.place(x=190, y=130, anchor=E)
        self.target_sn_entry = Entry(self.input_frame,
                                     width=6,
                                     justify=CENTER,
                                     textvariable=DoubleVar(value=ini_sn),
                                     font=self.font)
        self.target_sn_entry.place(x=190, y=130, anchor=W)

        # Target Magnitude (AB)
        self.magnitude_label = Label(self.input_frame,
                                     text="Target Magnitude (AB):",
                                     font=self.font,
                                     bg=c2)
        self.magnitude_label.place(x=20, y=170, anchor=W)

        self.mag_blue_label = Label(self.input_frame,
                                    text="Blue",
                                    font=self.font,
                                    bg=c2)
        self.mag_blue_label.place(x=20, y=200, anchor=W)
        self.mag_green_label = Label(self.input_frame,
                                     text="Green",
                                     font=self.font,
                                     bg=c2)
        self.mag_green_label.place(x=90, y=200, anchor=W)
        self.mag_red_label = Label(self.input_frame,
                                   text="Red",
                                   font=self.font,
                                   bg=c2)
        self.mag_red_label.place(x=160, y=200, anchor=W)
        self.mag_nir_label = Label(self.input_frame,
                                   text="NIR",
                                   font=self.font,
                                   bg=c2)
        self.mag_nir_label.place(x=230, y=200, anchor=W)

        self.mag_blue_entry = Entry(self.input_frame,
                                    width=6,
                                    justify=CENTER,
                                    textvariable=DoubleVar(value=ini_min_mag),
                                    font=self.font)
        self.mag_blue_entry.place(x=20, y=230, anchor=W)
        self.mag_green_entry = Entry(self.input_frame,
                                     width=6,
                                     justify=CENTER,
                                     textvariable=DoubleVar(value=ini_min_mag),
                                     font=self.font)
        self.mag_green_entry.place(x=90, y=230, anchor=W)
        self.mag_red_entry = Entry(self.input_frame,
                                   width=6,
                                   justify=CENTER,
                                   textvariable=DoubleVar(value=ini_min_mag),
                                   font=self.font)
        self.mag_red_entry.place(x=160, y=230, anchor=W)
        self.mag_nir_entry = Entry(self.input_frame,
                                   width=6,
                                   justify=CENTER,
                                   textvariable=DoubleVar(value=ini_min_mag),
                                   font=self.font)
        self.mag_nir_entry.place(x=230, y=230, anchor=W)

        self.set_wave_entry = Entry(self.input_frame,
                                    width=6,
                                    justify=CENTER,
                                    textvariable=DoubleVar(value=ini_wave),
                                    font=self.font,
                                    bg="khaki")
        self.set_wave_entry.place(x=300, y=200, anchor=W)

        self.mag_wave_entry = Entry(self.input_frame,
                                    width=6,
                                    justify=CENTER,
                                    textvariable=DoubleVar(value=ini_min_mag),
                                    font=self.font,
                                    bg="khaki")
        self.mag_wave_entry.place(x=300, y=230, anchor=W)

        # Sky Brightness (AB)
        self.sky_label = Label(self.input_frame,
                               text="Sky Brightness (AB):",
                               font=self.font,
                               bg=c2)
        self.sky_label.place(x=20, y=290, anchor=W)

        self.sky_blue_label = Label(self.input_frame,
                                    text="Blue",
                                    font=self.font,
                                    bg=c2)
        self.sky_blue_label.place(x=20, y=320, anchor=W)
        self.sky_green_label = Label(self.input_frame,
                                     text="Green",
                                     font=self.font,
                                     bg=c2)
        self.sky_green_label.place(x=90, y=320, anchor=W)
        self.sky_red_label = Label(self.input_frame,
                                   text="Red",
                                   font=self.font,
                                   bg=c2)
        self.sky_red_label.place(x=160, y=320, anchor=W)
        self.sky_nir_label = Label(self.input_frame,
                                   text="NIR",
                                   font=self.font,
                                   bg=c2)
        self.sky_nir_label.place(x=230, y=320, anchor=W)

        self.sky_blue_entry = Entry(self.input_frame,
                                    width=6,
                                    justify=CENTER,
                                    textvariable=DoubleVar(value=ini_sky[0]),
                                    font=self.font)
        self.sky_blue_entry.place(x=20, y=350, anchor=W)
        self.sky_green_entry = Entry(self.input_frame,
                                     width=6,
                                     justify=CENTER,
                                     textvariable=DoubleVar(value=ini_sky[1]),
                                     font=self.font)
        self.sky_green_entry.place(x=90, y=350, anchor=W)
        self.sky_red_entry = Entry(self.input_frame,
                                   width=6,
                                   justify=CENTER,
                                   textvariable=DoubleVar(value=ini_sky[2]),
                                   font=self.font)
        self.sky_red_entry.place(x=160, y=350, anchor=W)
        self.sky_nir_entry = Entry(self.input_frame,
                                   width=6,
                                   justify=CENTER,
                                   textvariable=DoubleVar(value=ini_sky[3]),
                                   font=self.font)
        self.sky_nir_entry.place(x=230, y=350, anchor=W)

        self.sky_wave_entry = Entry(self.input_frame,
                                    width=6,
                                    justify=CENTER,
                                    textvariable=DoubleVar(value=ini_sky[4]),
                                    font=self.font,
                                    bg="khaki")
        self.sky_wave_entry.place(x=300, y=350, anchor=W)

        # Mag. Range (AB)
        self.mag_range_label = Label(self.input_frame,
                                     text="Mag. Range (AB):",
                                     font=self.font,
                                     bg=c2)
        self.mag_range_label.place(x=400, y=80, anchor=W)

        self.min_mag_entry = Entry(self.input_frame,
                                   width=6,
                                   justify=CENTER,
                                   textvariable=DoubleVar(value=ini_min_mag),
                                   font=self.font)
        self.min_mag_entry.place(x=550, y=80, anchor=W)
        self.max_mag_entry = Entry(self.input_frame,
                                   width=6,
                                   justify=CENTER,
                                   textvariable=DoubleVar(value=ini_max_mag),
                                   font=self.font)
        self.max_mag_entry.place(x=640, y=80, anchor=W)

        self.bar_label = Label(self.input_frame,
                               text="-",
                               font=self.font,
                               bg=c2)
        self.bar_label.place(x=620, y=80, anchor=W)

        # Wave. Range
        self.wave_range_label = Label(self.input_frame,
                                      text="Wave. Range:",
                                      font=self.font,
                                      bg=c2)
        self.wave_range_label.place(x=400, y=170, anchor=W)

        self.wave_mode = StringVar()
        self.wave_mode.set("Blue")

        self.wave_blue_radio = Radiobutton(self.input_frame,
                                           text="Blue",
                                           variable=self.wave_mode,
                                           value="Blue",
                                           command=self.ui_wave_enable,
                                           font=self.font,
                                           bg=c2)
        self.wave_blue_radio.place(x=520, y=170, anchor=W)

        self.wave_green_radio = Radiobutton(self.input_frame,
                                            text="Green",
                                            variable=self.wave_mode,
                                            value="Green",
                                            command=self.ui_wave_enable,
                                            font=self.font,
                                            bg=c2)
        self.wave_green_radio.place(x=520, y=200, anchor=W)

        self.wave_red_radio = Radiobutton(self.input_frame,
                                          text="Red",
                                          variable=self.wave_mode,
                                          value="Red",
                                          command=self.ui_wave_enable,
                                          font=self.font,
                                          bg=c2)
        self.wave_red_radio.place(x=520, y=230, anchor=W)

        self.wave_nir_radio = Radiobutton(self.input_frame,
                                          text="NIR",
                                          variable=self.wave_mode,
                                          value="NIR",
                                          command=self.ui_wave_enable,
                                          font=self.font,
                                          bg=c2)
        self.wave_nir_radio.place(x=520, y=260, anchor=W)

        self.set_wave_radio = Radiobutton(self.input_frame,
                                          text="",
                                          variable=self.wave_mode,
                                          value="Input Wave",
                                          command=self.ui_wave_enable,
                                          font=self.font,
                                          bg=c2)
        self.set_wave_radio.place(x=520, y=290, anchor=W)

        self.min_wave_entry = Entry(self.input_frame,
                                    width=6,
                                    justify=CENTER,
                                    textvariable=DoubleVar(value=ini_min_wave),
                                    font=self.font,
                                    bg="khaki")
        self.min_wave_entry.place(x=550, y=290, anchor=W)

        self.max_wave_entry = Entry(self.input_frame,
                                    width=6,
                                    justify=CENTER,
                                    textvariable=DoubleVar(value=ini_max_wave),
                                    font=self.font,
                                    bg="khaki")
        self.max_wave_entry.place(x=640, y=290, anchor=W)

        self.bar_label = Label(self.input_frame,
                               text="-",
                               font=self.font,
                               bg=c2)
        self.bar_label.place(x=620, y=290, anchor=W)

        # Run & Save
        self.execute_window = PanedWindow(self.master, orient="vertical")
        self.execute_frame = LabelFrame(self.execute_window, bg=c0, bd=0)
        self.execute_window.add(self.execute_frame)
        self.execute_window.place(x=0, y=735, width=800, height=65)

        self.run_button = Button(self.execute_frame,
                                 text="RUN ONLY",
                                 width=15,
                                 command=self.run,
                                 font=self.font,
                                 bg=c3)
        self.run_button.place(relx=0.35, rely=0.5, anchor=CENTER)

        self.run_button = Button(self.execute_frame,
                                 text="RUN & SAVE",
                                 width=15,
                                 command=self.run_save,
                                 font=self.font,
                                 bg=c3)
        self.run_button.place(relx=0.65, rely=0.5, anchor=CENTER)

        # Global variables
        self.mag = 0
        self.sky = 0
        self.min_wave = 0
        self.max_wave = 0

        # GUI Initialization
        self.ui_enable()
        self.ui_wave_enable()

        self.mode_func = functions.Functions()
        print('...... Done!')
Exemplo n.º 16
0
client.on_connect = on_connect
client.on_disconnect = on_disconnect
client.on_message = on_message
print("Connecting to broker ", broker)

client.connect(broker)  #connect to broker
client.loop_start()  #start loop
###### END MQTT ######

_starting_time = datetime.datetime.now().timestamp() + 3600
my_ts = Timestamp.MyTimestamp(_starting_time)
print(my_ts.getFullTs())

my_db = mongodb.MyDB("bin_simulation", _starting_time)
my_const = c.Constants(my_db)
my_func = f.Functions(my_const, my_db)

###### START PROGRAM ######
bins = {}
littering = 0


def throwOut_trash(my_bins, the_bin, my_current, w_type, nearest=1):
    nearest += 1
    if ((my_current + my_bins[the_bin]['levels'][w_type]) <=
            my_bins[the_bin]['total_height']):
        my_bins[the_bin]['levels'][waste_type] += current
    else:
        print(my_bins[the_bin]["bin_id"], ": ", waste_type, "full")
        new_bin = my_func.calculateNeighbours(my_bins[key], nearest)
        print("throw out in bin", new_bin)
Exemplo n.º 17
0
    def start(self,inputFile, outputFile):

        _jsonLib = jsonLib.JsonLib(self._constants)   

        variables = self._constants._PATH_VARIABLES
        textType = _jsonLib.getValue(variables,self._constants._FIELD_TEXT_TYPE)
        textTypeCodecs = _jsonLib.getValue(variables,self._constants._FIELD_TEXT_TYPE_CODECS)
        languageType = _jsonLib.getValue(variables,self._constants._FIELD_LANGUAGE_CURRENT)
        languagePath = _jsonLib.getValue(variables,self._constants._PATH_LANGUAGE)+languageType+self._constants._EXTENSION_JSON 
        extension = os.path.splitext(inputFile)[self._constants._INDEX_POSITION_EXTENSION][self._constants._INDEX_POSITION_SPLIT_ORDER:]

        if (inputFile == self._constants._FIELD_EMPTY_STRING or outputFile == self._constants._FIELD_EMPTY_STRING):
            print(_jsonLib.getValue(languagePath,self._constants._FIELD_ERROR_PARAMETERS))
            return self._constants._INDEX_RETURN_ERROR 

        if not (os.path.isfile(inputFile)):
            print(_jsonLib.getValue(languagePath,self._constants._FIELD_ERROR_INPUT))
            return self._constants._INDEX_RETURN_ERROR        
        if (not (os.path.dirname(outputFile))) and (os.path.dirname(outputFile) != self._constants._FIELD_EMPTY_STRING):
            print(_jsonLib.getValue(languagePath,self._constants._FIELD_ERROR_OUTPUT))
            return self._constants._INDEX_RETURN_ERROR
        if not (extension in _jsonLib.getValue(variables,self._constants._FIELD_IMAGE_EXTENSION)):
            print(_jsonLib.getValue(languagePath,self._constants._FIELD_ERROR_FILE_TYPE))
            return self._constants._INDEX_RETURN_ERROR    

        print(_jsonLib.getValue(languagePath,self._constants._FIELD_MESSAGE_WELCOME)) 

        internalImage = _jsonLib.getValue(variables,self._constants._FIELD_IMAGE_FILENAME)
        internalText = _jsonLib.getValue(variables,self._constants._FIELD_TEXT_FILENAME)
        
        _image = image.Image(self._constants)
        _image.fixImage(inputFile,internalImage)
        if (_image):
            del _image

        _ocr = ocr.Ocr(self._constants)
        _ocr.readPhoto(internalImage,internalText,textTypeCodecs)
        if (_ocr):
            del _ocr

        _spellcheck = spellcheck.Spellcheck(self._constants)
        _spellcheck.verifyFile(internalText,languageType,textType,textTypeCodecs)
        if (_spellcheck):
            del _spellcheck

        ttsLanguage = _jsonLib.getValue(languagePath,self._constants._FIELD_GTTS_CODE)
        _tts = tts.Tts(self._constants)
        audioExists = _tts.convertText(internalText,outputFile,ttsLanguage)
        if (_tts):
            del _tts

        if (audioExists == self._constants._INDEX_RETURN_OK):
            print(_jsonLib.getValue(languagePath,self._constants._FIELD_MESSAGE_FINISH))
        
        if (_jsonLib):
            del _jsonLib

        _functions = functions.Functions(self._constants)
        _functions.clearAll(internalImage,internalText)
         if (_functions):
            del _functions
Exemplo n.º 18
0
import functions as Fun

MONGO_ADDR = os.environ["AMP_AMPDB_ADDR"]
VIEWSDB_ADDR = os.environ["AMP_VIEWSDB_ADDR"]
PICDB_ADDR = os.environ['AMP_PICDB_ADDR']

ampDBClient = pymongo.MongoClient(MONGO_ADDR)
db = ampDBClient.ampnadoDB

ampVDBClient = pymongo.MongoClient(VIEWSDB_ADDR)
viewsdb = ampVDBClient.ampviewsDB

ampPDBClient = pymongo.MongoClient(PICDB_ADDR)
pdb = ampPDBClient.picdb

FUN = Fun.Functions()
RAND = Fun.RandomArtDb()

define(
    'server_port',
    default=os.environ["AMP_SERVER_PORT"],
    help='run on the given port',
    type=int,
)

off_set = int(os.environ["AMP_OFFSET_SIZE"])


class Application(tornado.web.Application):
    def __init__(self):
        mpath = os.environ["AMP_MEDIA_PATH"]
Exemplo n.º 19
0
class Ticket(cmd.Cmd):

    intro = 'Welcome to Ticket booking service!' \
        + ' (type help for a list of commands.)'
    print(__doc__)
    prompt = 'events>> '
    file = None

    funt = functions.Functions()

    @docopt_cmd
    def do_create(self, arg):
        """Usage: create <name> <start_date-yyyy/mm/dd> <end_date-yyyy/mm/dd> <venue>"""
        try:
            name = arg['<name>']
            start = datetime.datetime.strptime(arg['<start_date-yyyy/mm/dd>'],
                                               "%Y/%m/%d")
            end = datetime.datetime.strptime(arg['<end_date-yyyy/mm/dd>'],
                                             "%Y/%m/%d")
            venue = arg['<venue>']
            print(self.funt.create_event(name, start, end, venue))
        except ValueError:
            print(colored("Invalid input", 'red'))

    @docopt_cmd
    def do_delete(self, arg):
        """Usage: delete <event_id>"""
        event = arg['<event_id>']
        print(self.funt.delete_event(event))

    @docopt_cmd
    def do_edit(self, arg):
        """Usage: edit <event_id> <name> <start_date-yyyy/mm/dd> <end_date-yyyy/mm/dd> <venue> """

        try:
            id = arg['<event_id>']
            name = arg['<name>']
            start = datetime.datetime.strptime(arg['<start_date-yyyy/mm/dd>'],
                                               "%Y/%m/%d")
            end = datetime.datetime.strptime(arg['<end_date-yyyy/mm/dd>'],
                                             "%Y/%m/%d")
            venue = arg['<venue>']

            print(self.funt.update_event(id, name, start, end, venue))

        except ValueError:
            print(colored("Invalid argument", 'red'))

    @docopt_cmd
    def do_list(self, arg):
        """Usage: list"""
        events = self.funt.list()

    @docopt_cmd
    def do_view(self, arg):
        """Usage: view <event_id>"""

        print(self.funt.view_event(int(arg['<event_id>'])))

    @docopt_cmd
    def do_generate(self, arg):
        """Usage: generate <email>"""
        try:
            print(self.funt.generate_ticket(arg['<email>']))
        except smtplib.SMTPException:
            print(
                colored("Error: unable to send email, Invalid email address",
                        'red'))

    @docopt_cmd
    def do_invalidate(self, arg):
        """Usage: invalidate <ticket_id>"""

        print(self.funt.invalidate_ticket(int(arg['<ticket_id>'])))

    def do_quit(self, arg):
        """Quits out of Interactive Mode."""

        print(
            colored('Thanks for booking, feel free to book with us anytime',
                    'green'))
        exit()
Exemplo n.º 20
0
input_entry = ttk.Entry(input_frame,
                        textvariable=input_var,
                        font=('Arial', 15))
input_entry.grid(row=0, column=1)

# output frame
output_frame = ttk.Frame(root)
output_frame.grid(row=2)

output_label = ttk.Label(output_frame, text='Result: ')
output_label.grid(row=0, column=0)
output_entry = ttk.Entry(output_frame, font=('Arial', 15))
output_entry.grid(row=0, column=1)

# initialise Functions object
funcs = functions.Functions(input_entry, output_entry)
input_var.trace_add('write', funcs.input_tracer)

# button frame
button_frame = ttk.Frame(root)
button_frame.grid(row=1)

unit_outputs = dict()

ttk.Button(button_frame,
           text='kg to lb',
           command=lambda: funcs.conv("kg_to_lb")).grid(row=0,
                                                        column=0,
                                                        ipady=10)
unit_outputs['kg_to_lb'] = ttk.Entry(button_frame, font=('Arial', 13))
unit_outputs['kg_to_lb'].grid(row=1, column=0, ipady=10)
Exemplo n.º 21
0
P_sc.start()

T_sc = RPIservo.ServoCtrl()
T_sc.start()


# modeSelect = 'none'
modeSelect = 'PT'

init_pwm0 = scGear.initPos[0]
init_pwm1 = scGear.initPos[1]
init_pwm2 = scGear.initPos[2]
init_pwm3 = scGear.initPos[3]
init_pwm4 = scGear.initPos[4]

fuc = functions.Functions()
fuc.start()

curpath = os.path.realpath(__file__)
thisPath = "/" + os.path.dirname(curpath)

direction_command = 'no'
turn_command = 'no'

def servoPosInit():
	scGear.initConfig(2,init_pwm2,1)
	P_sc.initConfig(1,init_pwm1,1)
	T_sc.initConfig(0,init_pwm0,1)


def replace_num(initial,new_num):   #Call this function to replace data in '.txt' file
Exemplo n.º 22
0
import pandas as pd
import functions

arquivo = functions.Functions()

arquivo.readFileExcel(
    'C:/Users/ddonida/Documents/Curso/ReadingExcelFile/example.xlsx')

print(arquivo.lerArquivo())  #mostra o arquivo lido na saída

print('')

print(arquivo.filterColumn(
    'Letras'))  #filtra a tabela: mostra apenas os dados da coluna 'Letras'

print('')

print(arquivo.describe())  #descrição dos dados da tabela

print('')

print(arquivo.shape())  #tamanho da tabela (linhasxcolunas)
Exemplo n.º 23
0
                    dest='gpu',
                    help='Use gpu for processing')

# python predict.py flowers/valid/1/image_06739.jpg checkpoints --category_names cat_to_name.json --gpu
# Get arguments
args = parser.parse_args()

# Select Device
device = "cuda"
if  not args.gpu:
    device = "cpu"
print("Device set to " + device)

## Loading the checkpoint
# Load model
f = functions.Functions()
model = f.load_checkpoint(args.checkpoint)

## Class Prediction function
valid_transforms = transforms.Compose([transforms.Resize(256),
                                           transforms.CenterCrop(224),
                                           transforms.ToTensor(),
                                           transforms.Normalize(mean=[0.485, 0.456, 0.406], 
                                           std=[0.229, 0.224, 0.225])])
valid_data = datasets.ImageFolder(args.path_to_image.split('/')[0] + "/" + args.path_to_image.split('/')[1], transform=valid_transforms)

# Run the prediction for all the images in a random folder
class_names = valid_data.classes
probs, classes = f.predict(args.path_to_image, model.to(device), valid_transforms, device, args.top_k)

if args.category_names:
Exemplo n.º 24
0
import DES
import functions
import numpy as np
import bitarray
import time
import multiprocessing
import key_scheduler
import pad
from tkinter import *
from tkinter.ttk import Combobox
from tkinter import filedialog
import hash
import DES_decrypt


obj = functions.Functions()

if __name__ == "__main__":
    win = Tk()
    win.geometry("300x450")

    fun = functions.Functions()

    plaintext = bitarray.bitarray([])
    flag = 0  # flag=0:incomplete parameters, flag=1:Encrypt, flag=2:Decrypt
    no_of_processes = 0
    file_selected = 0
    data_checked = False
    out_dir = ''