def start_uploading(settings):
    """
    start uploading process based on "upload_scheduler.txt"

    :return: None
    """
    today = datetime.date.today()
    with open("upload_scheduler.txt", "r") as f:
        lines = [l for l in f if l.strip()]

        for i, lin in enumerate(lines):
            path, time, status = lin.split()
            program = os.path.basename(os.path.dirname(path))
            target_date = datetime.datetime.strptime(time, "%Y-%m-%d").date()

            if status == "pending" and target_date == today:
                if program not in args.observing_programs:
                    Message.addMessage(
                        "skipping uploading program: {} ({})".format(
                            program, os.path.basename(path)),
                        dump="header")
                    continue

                Message.clearMessage("program")
                Message.clearMessage("session")
                Message.clearMessage("download")
                Message.clearMessage("log")

                upload = settings[program].get("upload", "no").lower()
                if upload == "ivs":
                    code = os.path.basename(os.path.dirname(path))
                    Transfer.upload(path)
                    emails = Helper.read_emails(settings[program],
                                                args.fallback_email)
                    SendMail.writeMail_upload(code, emails)
                elif upload == "no":
                    pass
                elif upload == "gow":
                    code = os.path.basename(os.path.dirname(path))
                    Transfer.upload_GOW_ftp(path)
                    emails = Helper.read_emails(settings[program],
                                                args.fallback_email)
                    SendMail.writeMail_upload(code, emails)
                else:
                    emails = upload.split(",")
                    with open(os.path.join(path, "selected", "email.txt"),
                              "r") as f:
                        body = f.read()
                    SendMail.writeMail(os.path.join(path, "selected"), emails,
                                       body)

                lines[i] = lin.replace("pending", "uploaded")

    with open("upload_scheduler.txt", "w") as f:
        for lout in lines:
            path, time, status = lout.split()
            target_date = datetime.datetime.strptime(time, "%Y-%m-%d").date()
            # do not list sessions older than 1 year in upload_scheduler.txt
            if target_date + datetime.timedelta(days=365) > today:
                f.write(lout)
Exemplo n.º 2
0
	def listen_worker():
		Transfer.listen(listenport)
		while True:
			global enemy_playerX
			string = Transfer.receive()
			
			if "Playerposition:" in string:
				string_list = string.split(":")
				enemy_playerX = int(float(string_list[1]))
			elif "Bomb:" in string:
				string_list = string.split(":")
				bomb_list.append([int(float(string_list[1])), enemy_playerY])
Exemplo n.º 3
0
    def post(self, request, filename, format=None):

        # .encode('utf-8').decode('utf-8-sig') will remove the \ufeff in the string when add string as value in
        # a dictionary.
        domain_file = request.data['domain'].encode('utf-8').decode(
            'utf-8-sig').lower()
        problem_file = request.data['problem'].encode('utf-8').decode(
            'utf-8-sig').lower()
        animation_file = request.data['animation'].encode('utf-8').decode(
            'utf-8-sig')

        # add url
        if "url" in request.data:
            url_link = request.data['url']
        else:
            url_link = "http://solver.planning.domains/solve"

        predicates_list = Domain_parser.get_domain_json(domain_file)
        plan = Plan_generator.get_plan(domain_file, problem_file, url_link)
        problem_dic = Problem_parser.get_problem_dic(problem_file,
                                                     predicates_list)

        object_list = Problem_parser.get_object_list(problem_file)
        animation_profile = json.loads(
            Animation_parser.get_animation_profile(animation_file,
                                                   object_list))
        stages = Predicates_generator.get_stages(plan, problem_dic,
                                                 problem_file, predicates_list)
        objects_dic = Initialise.initialise_objects(stages["objects"],
                                                    animation_profile)

        myfile = open('stagejson', 'w')

        # Write a line to the file
        myfile.write(json.dumps(stages))
        # Close the file
        myfile.close()

        myfile = open('objects_dic', 'w')

        # Write a line to the file
        myfile.write(json.dumps(objects_dic))
        # Close the file
        myfile.close()
        myfile = open('animation_profile', 'w')

        # Write a line to the file
        myfile.write(json.dumps(animation_profile))
        # Close the file
        myfile.close()

        result = Solver.get_visualisation_dic(stages, animation_profile,
                                              plan['result']['plan'],
                                              problem_dic)

        visualisation_file = Transfer.generate_visualisation_file(
            result, list(objects_dic.keys()), animation_profile,
            plan['result']['plan'])

        return Response(visualisation_file)
Exemplo n.º 4
0
def updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel = None):
  if pComponent["componenttype"] == Cassette.componentType:
    return Cassette.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Add.componentType:
    return Add.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Evaporate.componentType:
    return Evaporate.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Transfer.componentType:
    return Transfer.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == React.componentType:
    return React.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Prompt.componentType:
    return Prompt.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Install.componentType:
    return Install.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Comment.componentType:
    return Comment.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == TrapF18.componentType:
    return TrapF18.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == EluteF18.componentType:
    return EluteF18.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Initialize.componentType:
    return Initialize.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Mix.componentType:
    return Mix.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Move.componentType:
    return Move.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == Summary.componentType:
    return Summary.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  elif pComponent["componenttype"] == ExternalAdd.componentType:
    return ExternalAdd.updateToComponent(pUnitOperation, nSequenceID, pComponent, username, database, systemModel)
  else:
    raise Exception("Unknown component type: " + pComponent["componenttype"])
Exemplo n.º 5
0
 def get_transfers_out_of_corp(db, corp_id):
     raw = db.execute(
         "SELECT * FROM transfers WHERE source=? ORDER BY date ASC",
         (corp_id, )).fetchall()
     return list(
         map(lambda t: Transfer.Transfer(t[0], t[1], t[2], t[3], t[4]),
             raw))
Exemplo n.º 6
0
def simulateNetworksThreadedFAST(param_value):
    folderPath = 'D:\\sensitivityAnalaysisVirtualSocFAST\\'
    explorationProbability = param_value[0]
    popularityPreferenceIntensity = param_value[1]
    connectionPercentageWithMatchedNodes = param_value[2]
    mutualPreferenceIntensity = [
        param_value[3], param_value[4], param_value[5]
    ]
    i = param_value[6]
    os.mkdir(folderPath + '\\' + str(i))

    graphTemp1 = RandomSocialGraphAdvanced(
        labelSplit=[100, 200, 300],
        connectionPercentageWithMatchedNodes=
        connectionPercentageWithMatchedNodes,
        explorationProbability=explorationProbability,
        addTraidtionalFeatures=False,
        additionalFeatureLen=3,
        npDistFunc=[
            'np.random.randint(18, high=80)', 'np.random.binomial(2, 0.5)'
        ],
        popularityPreferenceIntensity=popularityPreferenceIntensity,
        mutualPreferenceIntensity=mutualPreferenceIntensity)

    # graphTemp1 = RandomSocialGraphAdvanced(labelSplit=[100, 200, 300],
    #                                        connectionPercentageWithMatchedNodes=param_value[2],
    #                                        explorationProbability=param_value[0],
    #                                        addTraidtionalFeatures=False, additionalFeatureLen=3,
    #                                        npDistFunc=['np.random.randint(18, high=80)',
    #                                                    'np.random.binomial(2, 0.5)'],
    #                                        popularityPreferenceIntensity=param_value[1],
    #                                        mutualPreferenceIntensity=[param_value[3],param_value[4],param_value[5]])
    tp.WriteToFile(graphTemp1).easySaveEverything(folderPath + str(i) + '\\')
    i += 1
Exemplo n.º 7
0
def encode_old(reference, journal):
    """
    encode reference object to a specific journal
    :param reference: a Reference Object
    :param journal: any journal in Defs
    :return: formatted string
    """
    return Transfer.encode(reference, journal)
    def run(self, evt):
        t0 = time.time()
        print(self.num_steps, self.style_weight, self.content_weight, type(self.num_steps))

        if not self.StatusBar.busy:
            self.status2busy()
            Transfer(self.img_style, self.img_cont, "./data")
            self.timer.Start(1000)
Exemplo n.º 9
0
def simulateNetworksEasy2(folderPath):
    explorationProbabilityV = np.linspace(0.01, 0.1, 2)
    popularityPreferenceIntensityV = np.linspace(0.5, 1.5, 2)

    connectionPercentageWithMatchedNodesV = np.linspace(0.5, 2, 2)
    mutualPreferenceIntensityV = []
    len2 = np.random.uniform(low=0.7, high=1.0, size=2)
    len3 = np.random.uniform(low=0.3, high=0.7, size=2)
    len4 = np.random.uniform(low=0.0, high=0.3, size=2)

    for i in range(0, 2):
        mutualPreferenceIntensityV.append([len2[i], len3[i], len4[i]])

    # popularityPreferenceIntensityV = np.arange(1,10,1)
    # popularityPreferenceIntensityV = popularityPreferenceIntensityV.tolist()

    for explorationProbability in explorationProbabilityV:
        for connectionPercentageWithMatchedNodes in connectionPercentageWithMatchedNodesV:
            for popularityPreferenceIntensity in popularityPreferenceIntensityV:
                for mutualPreferenceIntensity in mutualPreferenceIntensityV:
                    os.mkdir(folderPath + '\\' + 'EP' +
                             str(explorationProbability) + 'CPN' +
                             str(connectionPercentageWithMatchedNodes) + 'PP' +
                             str(popularityPreferenceIntensity) + 'mpi' +
                             str(mutualPreferenceIntensity[0]) +
                             str(mutualPreferenceIntensity[1]) +
                             str(mutualPreferenceIntensity[2]))

                    graphTemp1 = RandomSocialGraphAdvanced(
                        labelSplit=[500, 1000, 1500],
                        connectionPercentageWithMatchedNodes=
                        connectionPercentageWithMatchedNodes,
                        explorationProbability=explorationProbability,
                        addTraidtionalFeatures=False,
                        additionalFeatureLen=3,
                        npDistFunc=[
                            'np.random.randint(18, high=80)',
                            'np.random.binomial(2, 0.5)'
                        ],
                        popularityPreferenceIntensity=
                        popularityPreferenceIntensity,
                        mutualPreferenceIntensity=mutualPreferenceIntensity)
                    graphTemp1.mutateDNAandSocialise(mutationIntensity=0.3)
                    graphTemp1.socialise()
                    graphTemp1.mutateDNAandSocialise(mutationIntensity=0.7)
                    graphTemp1.socialise()
                    tp.WriteToFile(graphTemp1).easySaveEverything(
                        folderPath + '\\' + 'EP' +
                        str(explorationProbability) + 'CPN' +
                        str(connectionPercentageWithMatchedNodes) + 'PP' +
                        str(popularityPreferenceIntensity) + 'mpi' +
                        str(mutualPreferenceIntensity[0]) +
                        str(mutualPreferenceIntensity[1]) +
                        str(mutualPreferenceIntensity[2]) + '\\')
Exemplo n.º 10
0
def simulateNetworksEasymutualPreferenceIntensityTest2(folderPath):
    explorationProbabilityV = [0.5]
    popularityPreferenceIntensityV = [1]

    connectionPercentageWithMatchedNodesV = [10.00]
    mutualPreferenceIntensityV = []
    len2 = np.random.uniform(low=20, high=30, size=300)
    len3 = np.random.uniform(low=10, high=20, size=300)
    len4 = np.random.uniform(low=1, high=10, size=300)

    for i in range(0, 300):
        mutualPreferenceIntensityV.append([len2[i], len3[i], len4[i]])

    # popularityPreferenceIntensityV = np.arange(1,10,1)
    # popularityPreferenceIntensityV = popularityPreferenceIntensityV.tolist()

    for explorationProbability in explorationProbabilityV:
        for connectionPercentageWithMatchedNodes in connectionPercentageWithMatchedNodesV:
            for popularityPreferenceIntensity in popularityPreferenceIntensityV:
                for mutualPreferenceIntensity in mutualPreferenceIntensityV:
                    os.mkdir(folderPath + '\\' + 'EP' +
                             str("%6.5f" % explorationProbability) + 'CPN' +
                             str("%6.3f" %
                                 connectionPercentageWithMatchedNodes) + 'PP' +
                             str("%6.3f" % popularityPreferenceIntensity) +
                             'mpi' +
                             str("%6.3f" % mutualPreferenceIntensity[0]) +
                             str("%6.3f" % mutualPreferenceIntensity[1]) +
                             str("%6.3f" % mutualPreferenceIntensity[2]))

                    graphTemp1 = RandomSocialGraphAdvanced(
                        labelSplit=[100, 200, 300],
                        connectionPercentageWithMatchedNodes=
                        connectionPercentageWithMatchedNodes,
                        explorationProbability=explorationProbability,
                        addTraidtionalFeatures=False,
                        additionalFeatureLen=3,
                        npDistFunc=[
                            'np.random.randint(18, high=80)',
                            'np.random.binomial(2, 0.5)'
                        ],
                        popularityPreferenceIntensity=
                        popularityPreferenceIntensity,
                        mutualPreferenceIntensity=mutualPreferenceIntensity)
                    graphTemp1.socialise()
                    graphTemp1.socialise()
                    tp.WriteToFile(graphTemp1).easySaveEverything(
                        folderPath + '\\' + 'EP' +
                        str("%6.5f" % explorationProbability) + 'CPN' +
                        str("%6.3f" % connectionPercentageWithMatchedNodes) +
                        'PP' + str("%6.3f" % popularityPreferenceIntensity) +
                        'mpi' + str("%6.3f" % mutualPreferenceIntensity[0]) +
                        str("%6.3f" % mutualPreferenceIntensity[1]) +
                        str("%6.3f" % mutualPreferenceIntensity[2]) + '\\')
Exemplo n.º 11
0
def createFromComponent(nSequenceID,
                        pComponent,
                        username,
                        database,
                        systemModel=None):
    if pComponent["componenttype"] == Cassette.componentType:
        return Cassette.createFromComponent(nSequenceID, pComponent, username,
                                            database, systemModel)
    elif pComponent["componenttype"] == Add.componentType:
        return Add.createFromComponent(nSequenceID, pComponent, username,
                                       database, systemModel)
    elif pComponent["componenttype"] == Evaporate.componentType:
        return Evaporate.createFromComponent(nSequenceID, pComponent, username,
                                             database, systemModel)
    elif pComponent["componenttype"] == Transfer.componentType:
        return Transfer.createFromComponent(nSequenceID, pComponent, username,
                                            database, systemModel)
    elif pComponent["componenttype"] == React.componentType:
        return React.createFromComponent(nSequenceID, pComponent, username,
                                         database, systemModel)
    elif pComponent["componenttype"] == Prompt.componentType:
        return Prompt.createFromComponent(nSequenceID, pComponent, username,
                                          database, systemModel)
    elif pComponent["componenttype"] == Install.componentType:
        return Install.createFromComponent(nSequenceID, pComponent, username,
                                           database, systemModel)
    elif pComponent["componenttype"] == Comment.componentType:
        return Comment.createFromComponent(nSequenceID, pComponent, username,
                                           database, systemModel)
    elif pComponent["componenttype"] == TrapF18.componentType:
        return TrapF18.createFromComponent(nSequenceID, pComponent, username,
                                           database, systemModel)
    elif pComponent["componenttype"] == EluteF18.componentType:
        return EluteF18.createFromComponent(nSequenceID, pComponent, username,
                                            database, systemModel)
    elif pComponent["componenttype"] == Initialize.componentType:
        return Initialize.createFromComponent(nSequenceID, pComponent,
                                              username, database, systemModel)
    elif pComponent["componenttype"] == Mix.componentType:
        return Mix.createFromComponent(nSequenceID, pComponent, username,
                                       database, systemModel)
    elif pComponent["componenttype"] == Move.componentType:
        return Move.createFromComponent(nSequenceID, pComponent, username,
                                        database, systemModel)
    elif pComponent["componenttype"] == Summary.componentType:
        return Summary.createFromComponent(nSequenceID, pComponent, username,
                                           database, systemModel)
    elif pComponent["componenttype"] == ExternalAdd.componentType:
        return ExternalAdd.createFromComponent(nSequenceID, pComponent,
                                               username, database, systemModel)
    else:
        raise Exception("Unknown component type: " +
                        pComponent["componenttype"])
Exemplo n.º 12
0
def simulateNetworksEasy(folderPath):
    explorationProbabilityV = np.linspace(0.1, 0.5, 3)
    connectionPercentageWithMatchedNodesV = np.arange(5, 30, 3)

    # popularityPreferenceIntensityV = np.arange(1,10,1)
    # popularityPreferenceIntensityV = popularityPreferenceIntensityV.tolist()

    for explorationProbability in explorationProbabilityV:
        for connectionPercentageWithMatchedNodes in connectionPercentageWithMatchedNodesV:
            for popularityPreferenceIntensity in range(1, 5):
                os.mkdir(folderPath + '\\' + 'EP' +
                         str(explorationProbability) + 'CPN' +
                         str(connectionPercentageWithMatchedNodes) + 'PPV' +
                         str(popularityPreferenceIntensity))

                graphTemp1 = RandomSocialGraphAdvanced(
                    labelSplit=[500, 1000, 1500],
                    connectionPercentageWithMatchedNodes=
                    connectionPercentageWithMatchedNodes,
                    explorationProbability=explorationProbability,
                    addTraidtionalFeatures=True,
                    additionalFeatureLen=2,
                    npDistFunc=[
                        'np.random.randint(18, high=80)',
                        'np.random.binomial(2, 0.5)'
                    ],
                    popularityPreferenceIntensity=popularityPreferenceIntensity,
                    mutualPreferenceIntensity=[3, 2, 1])
                graphTemp1.mutateDNAandSocialise(mutationIntensity=0.3)
                graphTemp1.mutateDNAandSocialise(mutationIntensity=0.5)
                graphTemp1.mutateDNAandSocialise(mutationIntensity=0.7)

                graphTemp1.socialise()
                tp.WriteToFile(graphTemp1).easySaveEverything(
                    folderPath + '\\' + 'EP' + str(explorationProbability) +
                    'CPN' + str(connectionPercentageWithMatchedNodes) + 'PPV' +
                    str(popularityPreferenceIntensity) + '\\')
def start_scheduling(settings):
    """
    start VieSched++ AUTO processing

    :return: None
    """
    prefix = settings["general"].get("prefix_output_folder", "Schedules")
    if os.sep == "\\":
        prefix = prefix.replace("/", "\\")

    path_scheduler = settings["general"].get("path_to_scheduler")

    if not os.path.exists("upload_scheduler.txt"):
        with open("upload_scheduler.txt", "w"):
            pass

    Message.addMessage("VieSched++ AUTO report", dump="header")
    today = datetime.date.today()
    Message.addMessage("date: {:%B %d, %Y}".format(today), dump="header")
    Message.addMessage("computer: {}, Python {}".format(
        platform.node(), platform.python_version()),
                       dump="header")
    if settings["general"].get("institute") is not None:
        Message.addMessage("institution: {}".format(
            settings["general"].get("institute")),
                           dump="header")
    Message.addMessage(
        "This is an automatically generated message. Do NOT reply to this email directly!",
        dump="header")
    # download files
    if not args.no_download:
        Transfer.download_ftp()
        Transfer.download_http()
    else:
        Message.addMessage("no downloads", dump="header")

    # start processing all programs
    for program in settings.sections():
        if program == "general":
            continue
        if program not in args.observing_programs:
            print("skipping scheduling observing program: {}".format(program))
            continue

        s_program = settings[program]
        emails = Helper.read_emails(s_program, args.fallback_email)
        delta_days = s_program.get("schedule_date", "10")
        if args.date is not None:
            try:
                target_day = datetime.datetime.strptime(args.date, '%Y-%m-%d')
                delta_days = (target_day.date() - today).days
                year = target_day.year % 100
            except ValueError:
                print("ERROR while interpreting target date (-d option): {}".
                      format(args.date))
                print(
                    "    must be in format \"yyyy-mm-dd\" (e.g.: 2020-01-31)")
                return
        else:
            try:
                target_day = datetime.datetime.strptime(delta_days, '%Y-%m-%d')
                delta_days = (target_day.date() - today).days
                year = target_day.year % 100
            except ValueError:
                if delta_days.isnumeric():
                    delta_days = int(delta_days)
                    target_day = today + datetime.timedelta(days=delta_days)
                    year = target_day.year % 100
                else:
                    delta_days = delta_days.lower()
                    year = today.year % 100

        delta_days_upload = s_program.getint("upload_date", 7)
        statistic_field = s_program.get("statistics").split(",")
        upload = True
        if s_program.get("upload", "no").lower() == "no":
            upload = False

        # read master files
        template_master = Template(s_program.get("master", "master$YY.txt"))
        master = template_master.substitute(YY=str(year))

        master = os.path.join("MASTER", master)
        sessions = Helper.read_master(master)

        try:
            pattern = s_program["pattern"]
            f = Helper.find_function(select_best_functions,
                                     s_program["function"])[0]
            f_pre = Helper.find_function(
                pre_scheduling_functions,
                s_program.get("pre_scheduling_functions", ""))
            f_post = Helper.find_function(
                post_scheduling_functions,
                s_program.get("post_scheduling_functions", ""))

            start(sessions, path_scheduler, program, pattern, f, emails,
                  delta_days, delta_days_upload, statistic_field, prefix,
                  upload, f_pre, f_post)

        except:
            Message.addMessage("#### ERROR ####")
            Message.addMessage(traceback.format_exc())
            SendMail.writeErrorMail(emails)
Exemplo n.º 14
0
 def transfer(self):
     self.root.destroy()
     obj2 = Transfer.transfer_class(self.id)
Exemplo n.º 15
0
			if event.type == QUIT:
				pygame.quit()
				sys.exit()
			elif event.type == pygame.MOUSEBUTTONDOWN:
				Released = False
				Pressed = True
				Down = True
			elif event.type == pygame.MOUSEBUTTONUP:
				Released = True
				Pressed = False
				Down = False
			elif event.type == pygame.KEYDOWN:
				if Grinch_start == True:
					bomb_list.append([current_playerX, current_playerY])
					if Grinch_start == True:
						Transfer.send(sendip, semdport, str("Bomb:" + str(current_playerX)))
									
		if Pressed == True:
			mouse_x, mouse_y = pygame.mouse.get_pos()
			if mouse_x > current_playerX and mouse_x < current_playerX + current_image.get_width() and mouse_y > current_playerY and mouse_y < current_playerY + current_image.get_height():
				current_playerX = mouse_x - current_image.get_width() / 2
				Transfer.send(sendip, semdport, str("Playerposition:" + str(current_playerX)))
					
		if Down and Target != None:
			Target.pos = pos
		if Released:
			Target = None
		
		pygame.display.update()
		fpsClock.tick(FPS)
		
    def checkDetails(self):
        con = cx_Oracle.connect('surya/peace@localhost/xe')
        cur = con.cursor()
        i = 0
        d = 1
        count = 0
        print("\n\n\t\tSign In To Your Account\n")
        while (i != 1):
            cust = input("Enter Customer Id: ")
            try:
                cur.execute(
                    "select CUSTOMER_ID,STATUS from CUSTOMER_DETAILS where CUSTOMER_ID=:1",
                    (cust, ))
                user1 = cur.fetchall()
                self.cid = user1[0][0]
                '''print(cid)'''
                if (self.cid == int(cust)):
                    cst = user1[0][1]
                    if (cst == 'OPEN'):
                        break
                    else:
                        print("Your Account is Blocked/Closed.")
                        d = 0
                    break
            except:
                print("Invalid customer id.Please Enter again!")
        while (d != 0):
            pwd = input("Enter password:"******"select password from CUSTOMER_DETAILS where password=:m and CUSTOMER_ID=:1",
                    (
                        pwd,
                        self.cid,
                    ))
                u = cur.fetchall()
                p = u[0][0]
                if (p == pwd):
                    print("\n\tSuccessfully Logged In!")
                    count = 0
                    ach = 0
                    while (ach != 7):
                        print('\n\t\tUser Menu')
                        print('\n\t1.Address Change')
                        print('\n\t2.Money Deposit')
                        print('\n\t3.Money Withdrawal')
                        print('\n\t4.Print Statement')
                        print('\n\t5.Transfer Money')
                        print('\n\t6.Account Closure')
                        print('\n\t7.Customer Logout')
                        adch = input("\n\nSelect Option: ")
                        if adch == '1':
                            print('\n\n\t\tEnter New Address Details')
                            self.al1 = input('Address Line 1: ')
                            self.al2 = input('Address Line 2: ')
                            self.addr = self.al1 + ' ' + self.al2
                            self.city = input('City: ')
                            self.state = input('State: ')
                            f = 1
                            while (f != 0):
                                self.pin = input('Pincode: ')
                                tmp = self.pin
                                if (len(str(tmp)) != 6):
                                    print("Pincode should be of 6 digits.")
                                else:
                                    f = 0
                            try:
                                cur.execute(
                                    "UPDATE customer_details SET ADDRESS=:1,CITY=:2,STATE=:3,PINCODE=:4 WHERE CUSTOMER_ID=:5",
                                    (
                                        self.addr,
                                        self.city,
                                        self.state,
                                        self.pin,
                                        self.cid,
                                    ))
                                con.commit()
                                print(
                                    '\tAddress has been successfully updated')
                            except Exception as e:
                                print(e)
                                print("\tAddress Update Failed!! Try again")
                        elif adch == '2':
                            try:
                                dep = Deposit.Deposit()
                                dep.deposit()
                            except Exception as e:
                                print("Error: ", e)
                        elif adch == '3':
                            try:
                                w = Withdrawal.Withdrawal()
                                w.withdrawal()
                            except Exception as e:
                                print("Error: ", e)
                        elif adch == '4':
                            print('\n\n\t\tPrint Statement')
                            acc = input('Enter Account Number: ')
                            try:
                                cur.execute(
                                    "select ACCOUNT_NO from account_details where ACCOUNT_NO=:a AND CUSTOMER_ID=:c",
                                    {
                                        'a': acc,
                                        'c': self.cid
                                    })
                                user = cur.fetchall()
                                ac = user[0][0]
                                if ac == int(acc):
                                    tag = 1
                                    '''while (tag != 0):
                                        dateto = input("Enter Date To(mm/dd/yyyy): ")
                                        datefr = input("Enter Date From(mm/dd/yyyy): ")
                                        import time
                                        dt = time.strptime(dateto, "%m/%d/%Y")
                                        df = time.strptime(datefr, "%m/%d/%Y")
                                        if (dt > df):
                                            tag = 0
                                        else:
                                            print("\tDate To should be greater than Date From.\n\tEnter correct dates.")'''
                                    try:
                                        cur.execute(
                                            "select TRAN_DATE,CREDIT,DEBIT,CUR_BALANCE,ACCOUNT_NO from transaction_details where ACCOUNT_NO=:a",
                                            {
                                                'a': acc,
                                            })
                                        ad = cur.fetchall()
                                        an = ad[0][4]
                                        if an == int(acc):
                                            print(
                                                "\t   Transaction DATE\t\tTRANSACTION TYPE\tAMOUNT\tBALANCE"
                                            )
                                            for i in range(0, cur.rowcount):
                                                if ad[i][1] == 0:
                                                    print(
                                                        "\t", ad[i][0],
                                                        "\t\tDebit\t\t   ",
                                                        ad[i][2], " ",
                                                        ad[i][3])
                                                else:
                                                    print(
                                                        "\t", ad[i][0],
                                                        "\t\tCredit\t\t   ",
                                                        ad[i][1], " ",
                                                        ad[i][3])
                                    except Exception as e:
                                        print(e)
                                        print(
                                            "\tNo Transaction Record Found. Customer has not performed any transactions."
                                        )
                            except Exception as e:
                                print(e)
                                print(
                                    '\tInvalid Account Number!!\n\tTry again!!'
                                )
                        elif adch == '5':
                            try:
                                tra = Transfer.Transfer()
                                tra.transfer()
                            except:
                                pass
                                #print("Error: ", e)
                        elif adch == '6':
                            print('\n\n\t\tAccount Closure')
                            acc = input('Enter Account Number: ')
                            try:
                                cur.execute(
                                    "select ACCOUNT_NO from account_details where ACCOUNT_NO=:a AND CUSTOMER_ID=:c",
                                    {
                                        'a': acc,
                                        'c': self.cid
                                    })
                                user = cur.fetchall()
                                ac = user[0][0]
                                if ac == int(acc):
                                    try:
                                        cur.execute(
                                            "select S_ACCOUNT_NO,BALANCE from savings_account_details where S_ACCOUNT_NO=:1",
                                            (acc, ))
                                        ad = cur.fetchall()
                                        an = ad[0][0]
                                        if an == int(acc):
                                            b = ad[0][1]
                                            if b >= 2000:
                                                b = b - 2000
                                            cur.execute(
                                                "UPDATE savings_account_details SET STATUS='CLOSED',BALANCE=:1 WHERE S_ACCOUNT_NO=:2",
                                                (
                                                    b,
                                                    acc,
                                                ))
                                            cur.execute(
                                                "UPDATE customer_details SET STATUS='CLOSED' WHERE CUSTOMER_ID=:1",
                                                (self.cid, ))
                                            con.commit()
                                            print(
                                                "\tYour Savings Account ", an,
                                                " has been closed successfully."
                                            )
                                            print(
                                                "\tAn amount of Rs.", b,
                                                " will be send to your address."
                                            )
                                            print(
                                                "\tRs.2000 has been reduced from your account as account closure fee."
                                            )
                                    except Exception as e:
                                        print(e)
                                    try:
                                        cur.execute(
                                            "select C_ACCOUNT_NO,BALANCE from current_account_details where C_ACCOUNT_NO=:1",
                                            (acc, ))
                                        ad = cur.fetchall()
                                        an = ad[0][0]
                                        if an == int(acc):
                                            b = ad[0][1]
                                            if b >= 2000:
                                                b = b - 2000
                                            cur.execute(
                                                "UPDATE current_account_details SET STATUS='CLOSED',BALANCE=::1 WHERE C_ACCOUNT_NO=:2",
                                                (acc, ))
                                            cur.execute(
                                                "UPDATE customer_details SET STATUS='CLOSED' WHERE CUSTOMER_ID=:1",
                                                (self.cid, ))
                                            con.commit()
                                            print(
                                                "\tYour Current Account ", acc,
                                                "has been closed successfully."
                                            )
                                            print(
                                                "\tAn amount of Rs.", b,
                                                " will be send to your address."
                                            )
                                            print(
                                                "Rs.2000 has been reduced from your account as account closure fee."
                                            )
                                    except Exception as e:
                                        print("ERROR: ", e)
                            except Exception as e:
                                print(e)
                                print(
                                    "Account doesn't belong to your customer id"
                                )
                        elif adch == '7':
                            ach = 7
                        else:
                            print(
                                "Wrong Choice Entered. Please Enter Correct Choice"
                            )
                    break
            except:
                print("Invalid password.Please Enter again")
                count = count + 1
                if (count == 3):
                    print(
                        "\n\n\tSorry! You have made 3 unsuccessful attempts!Your account is Bloced!"
                    )
                    cur.execute(
                        "UPDATE customer_details SET STATUS='BLOCKED' WHERE CUSTOMER_ID=:1",
                        (self.cid, ))
                    con.commit()
                    break
        con.close()


#s=Signin()
#s.checkDetails()
Exemplo n.º 17
0
    args = parser.parse_args()

    logging.info('Loading original image %s' % (args.original_image))
    org_img = load_image(args.original_image)

    logging.info('Method to create mask')
    mask_type = args.mask

    logging.info('Loading style...')
    sty_list = args.style
    masks = args.mask

    mask_list = []
    for i in masks:
        mask_list.append(load_image(i))

    # make a transferor with all inputs, get transfered img.
    transferor = Transfer.Transferor()
    transferor.get_original(org_img)
    transferor.get_styles(sty_list)
    transferor.transfer_images()
    transfered_imgs = transferor.return_transfered_list()

    # make a blendor with all input, get blended img.
    blendor = Blend.Blendor()
    blendor.get_input(org_img, transfered_imgs)
    blendor.get_mask(mask_list)
    blendor.blend()
    blended_img = blendor.return_output()
    cv2.imwrite(args.transfered_image, blended_img)
 def transfer(self):
     self.rt.destroy()
     o8 = Transfer.trans_acc(self.admid)