Beispiel #1
0
def index():
    pa_list = []
    for c in db.get_list(db.PraticaAssistenza, 'user_id',
                         current_user.get_id()):
        pa_list.append(c.to_dict())

    return jsonify(results=pa_list)
Beispiel #2
0
def index():
    rs = []
    for c in db.get_list(db.RichiestaSoccorso, 'user_id',
                         current_user.get_id()):
        rs.append(c.to_dict())

    return jsonify(results=rs)
Beispiel #3
0
	def __init__(self):
		_list = get_list()
		index = 0
		self.choices = []
		self.devices = {}
		for name, ip in _list:
			key_value = 'dev' + str(index)
			self.choices.append((key_value, name))
			self.devices[key_value] = { 'name' : name, 'ip' : ip }
			index += 1
Beispiel #4
0
def get_list(update):
    list_id = database.get_list(update.message.chat_id)
    if not list_id:
        update.message.reply_text('Please, config a board and a list first!')
        return False

    trello_list = client.get_list(list_id)
    if not trello_list:
        update.message.reply_text('Failed to retrieve your list from trello!')
        return False

    return trello_list
Beispiel #5
0
    def on_change_choice_btn(self):

        if self.filter.currentText() == "trip_date":
            self.input_label.setPlaceholderText("YYYY-MM-DD")
            self.input_label.setCompleter(QCompleter([""]))
        else:
            self.input_label.setPlaceholderText("Enter " +
                                                self.filter.currentText())
            my_completer = QCompleter(
                database.get_list(self.filter.currentText()))
            my_completer.setCaseSensitivity(Qt.CaseInsensitive)
            self.input_label.setCompleter(my_completer)
Beispiel #6
0
def choose_words(email, nwords_to_send = 10):
    """
    Choose nwords_to_send words for user to learn. If less words are available
    only the available words will be sent.
    Words chosen will be assumed to be learned by user and are added to the
    user vocabulary in the db. User score in db is updated.
    """
    # query database for known words of user
    userwords = database.get_list(email)

    # create complete dict and remove known words
    unknown_words = reference_wordlist.copy()
    for w in userwords:
        unknown_words.pop(w,0)
 
    # convert unknown words dict to sorted list
    unknown_words = sorted(unknown_words,
            key=lambda x: unknown_words.get(x).freq, reverse=True)

    # at best we can send all the unknown words
    nwords_to_send = min(nwords_to_send, len(unknown_words))

    # query database for user score
    userscore = database.get_score(email)

    def add_word():
        target = int(percentile() * userscore * len(unknown_words))
        candidate = int(target * (1 + random.random() * (1 - percentile())))
        candidate = min(candidate, len(unknown_words) - 1)
        return unknown_words.pop(candidate)

    wordlist = [add_word() for i in range(nwords_to_send)]
  
    # new score and add words to db
    database.store_user_words(email, wordlist)
    newscore = score(wordlist + userwords)
    database.set_score(email, newscore)

    return wordlist
Beispiel #7
0
def choose_words(email, nwords_to_send=10):
    """
    Choose nwords_to_send words for user to learn. If less words are available
    only the available words will be sent.
    Words chosen will be assumed to be learned by user and are added to the
    user vocabulary in the db. User score in db is updated.
    """
    # query database for known words of user
    userwords = database.get_list(email)

    # create complete dict and remove known words
    unknown_words = reference_wordlist.copy()
    for w in userwords:
        unknown_words.pop(w, 0)

    # convert unknown words dict to sorted list
    unknown_words = sorted(unknown_words,
                           key=lambda x: unknown_words.get(x).freq,
                           reverse=True)

    # at best we can send all the unknown words
    nwords_to_send = min(nwords_to_send, len(unknown_words))

    # query database for user score
    userscore = database.get_score(email)

    def add_word():
        target = int(percentile() * userscore * len(unknown_words))
        candidate = int(target * (1 + random.random() * (1 - percentile())))
        candidate = min(candidate, len(unknown_words) - 1)
        return unknown_words.pop(candidate)

    wordlist = [add_word() for i in range(nwords_to_send)]

    database.store_user_words(email, wordlist)
    newscore = score(wordlist + userwords)
    database.set_score(email, newscore)

    return wordlist
Beispiel #8
0
def choose_words(userid, nwords_to_send = 10):
    """
    Choose words for user to learn. 
    """
    # query database for known words of user
    userwords = database.get_list(userid)

    # query database for user score
    userscore = database.get_score(userid)

    target = int(percentile() * userscore * words_in_language())
    
    # add a word not yet known to user to wordlist (ugly solution)
    def add_word(target,wordlist):
        tries = 0
        while tries < 1000:
            candidate = int(target * (1.0 + random.random() \
                * (1 - percentile())))
            tries += 1
            if candidate > words_in_language() + 1: 
                continue
            word = sorted_reference_wordlist[candidate] 
            if word not in wordlist:         
                return wordlist + [word]
        
        # can't find unknown words, returning whatever I have
        return wordlist + [word]

    wordlist = []
    
    for i in range(nwords_to_send):
        wordlist = add_word(target,wordlist)
   
    database.store_user_words(userid, wordlist)
    newscore = score(wordlist + userwords)
    database.set_score(newscore)

    return wordlist
Beispiel #9
0
    def set_up(self):
        self.date = QDate.currentDate().toString(Qt.ISODate) + "%"

        if self.period=="Month":
            self.date= self.date[:7] + "%"

        elif self.period=="Year":
            self.date= self.date[:4] + "%"

        print(self.date)


        self.input_date = QLineEdit()
        self.setFixedWidth(500)
        self.input_date.setPlaceholderText(self.placeholder)
        self.input_date.setText(self.date[:-1])
        self.details_btn = QPushButton("Details",self)
        self.details_btn.clicked.connect(self.on_click_details)

        choice = database.get_list("vehicle_no")
        choice.insert(0,"Net Profit")

        self.choice_graph_btn = QComboBox()
        self.choice_graph_btn.addItems(choice)
        #self.net_graph_btn.clicked.connect(self.on_click_net_Graph)

        self.view_graph_btn = QPushButton("View Graph",self)
        self.view_graph_btn.clicked.connect(self.on_click_view_Graph)

        self.total_profit = QLabel(database.get_total_profit_of_day(self.date))

        self.form_details.addRow(self.input_date , self.choice_graph_btn)
        self.form_details.addRow(self.details_btn , self.view_graph_btn)
        self.form_details.addRow(QLabel("Total profit of the "+self.period+" : "),self.total_profit)

        self.set_up_vehicle_details(self.date)
Beispiel #10
0
    def define_form(self):

        #self.vehicle_no.
        #self.no_of_trip
        self.date = QDate.currentDate().toString(Qt.ISODate)
        
        #lis = ["alpha","beta","alphaman","gamma"]
        #QCompleter(database.get_list(""))
        #comp.setCaseSensitivity(Qt.CaseInsensitive)
        #.setCompleter(QCompleter(database.get_list("")))

        #trip details
        self.material = QLineEdit()
        self.material.setCompleter(QCompleter(database.get_list("material")))
        self.loading_place = QLineEdit()
        self.loading_place.setCompleter(QCompleter(database.get_list("loading_place")))
        self.loading_machine = QLineEdit()
        self.loading_machine.setCompleter(QCompleter(database.get_list("loading_machine")))
        self.unloading_place = QLineEdit()
        self.unloading_place.setCompleter(QCompleter(database.get_list("unloading_place")))
        self.unloading_site = QLineEdit()
        self.unloading_site.setCompleter(QCompleter(database.get_list("unloading_site")))


        #purchase details
        self.purchase_quantity = QLineEdit()
        self.purchase_rate = QLineEdit()
        self.amount_purchase = QLabel()
        self.gst_bill_amount = QLineEdit()
        self.gst_bill_number = QLineEdit()
        self.total_amount_purchase = QLabel()

        #self.total_amount_purchase.mousePressEvent = self.testlink
        
        #sale details
        self.sale_quantity = QLineEdit()
        self.sale_price = QLineEdit()
        self.amount_sale = QLabel() 
        self.discount = QLineEdit()
        self.total_amount_sale = QLabel()


        #expenses details

        self.labour = QLineEdit()
        self.dalal_commision = QLineEdit()
        self.driver_commision = QLineEdit()
        self.toll_tax = QLineEdit()        
        self.cng_diesel_1 = QLineEdit()
        self.cng_diesel_2 = QLineEdit()
        self.police = QLineEdit()
        self.tyre_fitting_puncture = QLineEdit()
        self.air_grease_filter = QLineEdit()
        self.others = QLineEdit()
        self.expense_remarks = QLineEdit()
        self.total_expense_amount = QLabel()
        
        #vehicle breakdown details
        self.work_type = QLineEdit()
        self.work_type.setCompleter(QCompleter(database.get_list("work_type")))
        self.workshop_dealer = QLineEdit()
        self.workshop_dealer.setCompleter(QCompleter(database.get_list("workshop_dealer")))        
        

        mechanic_name_completer = QCompleter(database.get_list("mechanic_name_1")+database.get_list("mechanic_name_2")+database.get_list("mechanic_name_3"))
        status = ["","Paid By Driver","Paid By Owner","Unpaid"]

        self.no_of_repair = 3 #(QInputDialog.getInt(self,"Input","Enter No Of Breakdown Repairs :"))[0]
        self.mechanic_name_list = [0]*self.no_of_repair
        self.labour_charge_list = [0]*self.no_of_repair
        self.payment_status_list = [0]*self.no_of_repair
        
        for i in range(self.no_of_repair):
        	#self.mechanic_name_list[i]
        	#self.labour_charge_list[i]
        	#self.payment_status_list[i]
        
        	self.mechanic_name_list[i] = QLineEdit()
        	self.mechanic_name_list[i].setCompleter(mechanic_name_completer)
        	self.labour_charge_list[i] = QLineEdit()
        	self.labour_charge_list[i].setValidator(QDoubleValidator())
        	self.payment_status_list[i] = QComboBox()
        	self.payment_status_list[i].addItems(status)	


        self.spare_parts_dealer = QLineEdit()
        self.spare_parts_dealer.setCompleter(QCompleter(database.get_list("spare_parts_dealer")))
        self.spare_parts_cost = QLineEdit()
        self.spare_parts_cost_status = QComboBox()
        self.spare_parts_cost_status.addItems(status)        

        self.gst_spare_part = QLineEdit()
        self.gst_labour = QLineEdit()
        self.breakdown_remarks = QLineEdit()
        self.breakdown_amount_paid_by_driver = QLabel()
        self.breakdown_amount_paid_by_owner = QLabel()
        self.breakdown_amount_unpaid = QLabel()

        #driver details
        self.driver_name = QLineEdit()
        self.driver_name.setCompleter(QCompleter(database.get_list("driver_name")))
        self.royality = QLineEdit()
        self.payment_deposit_by_driver = QLineEdit()
        self.balance_forward_in_driver_account = QLabel(self.get_previous_balance_forward_for_next_trip())


        self.balance_of_stock = QLabel()
        self.in_hand_cash = QLabel()
        self.total_expense_paid_by_driver = QLabel()
        self.total_profit_of_trip = QLabel()
        self.royality_given_for_next_trip = QLineEdit()
        self.balance_forward_for_next_trip = QLabel()

        self.set_slots()
        ##signals self..editingFinished.connect(self.compute_) .editingFinished.connect(self.update_compute)

        # self.purchase_rate.editingFinished.connect(self.compute_amount_purchase)
        # self.gst_bill_amount.editingFinished.connect(self.compute_total_amount_purchase)
        # self.sale_price.editingFinished.connect(self.compute_amount_sale)
        # self.discount.editingFinished.connect(self.compute_total_amount_sale)
        # self.others.editingFinished.connect(self.compute_total_expense_amount)

        # self.breakdown_remarks.editingFinished.connect(self.compute_breakdown_amount_paid_by_driver)
        # self.breakdown_remarks.editingFinished.connect(self.compute_breakdown_amount_paid_by_owner)
        # self.breakdown_remarks.editingFinished.connect(self.compute_breakdown_amount_unpaid)

        # self.royality.editingFinished.connect(self.compute_balance_of_stock)
        # self.payment_deposit_by_driver.editingFinished.connect(self.compute_in_hand_cash)
        # self.royality_given_for_next_trip.editingFinished.connect(self.compute_balance_forward_for_next_trip)




        ##validators

        #purchase details
        self.purchase_quantity.setValidator(QDoubleValidator())
        self.purchase_rate.setValidator(QDoubleValidator())
        self.gst_bill_amount.setValidator(QDoubleValidator())


        #sale details
        self.sale_quantity.setValidator(QDoubleValidator())
        self.sale_price.setValidator(QDoubleValidator())
        self.discount.setValidator(QDoubleValidator())


        #expenses details
        self.labour.setValidator(QDoubleValidator())
        self.dalal_commision.setValidator(QDoubleValidator())
        self.driver_commision.setValidator(QDoubleValidator())
        self.toll_tax.setValidator(QDoubleValidator())
        self.cng_diesel_1.setValidator(QDoubleValidator())
        self.cng_diesel_2.setValidator(QDoubleValidator())
        self.police.setValidator(QDoubleValidator())
        self.tyre_fitting_puncture.setValidator(QDoubleValidator())
        self.air_grease_filter.setValidator(QDoubleValidator())
        self.others.setValidator(QDoubleValidator())
        
        
        #vehicle breakdown details
        self.spare_parts_cost.setValidator(QDoubleValidator())

        #driver details
        self.royality.setValidator(QDoubleValidator())
        self.payment_deposit_by_driver.setValidator(QDoubleValidator())
        self.royality_given_for_next_trip.setValidator(QDoubleValidator())



        width = 200
        
        #add to layout
        #trip details
        label1 = QLabel(" Material:")
        label1.setFixedWidth(width)
        self.layout_trip_details.addRow(label1, self.material)
        self.layout_trip_details.addRow(QLabel(" Loading Place:"), self.loading_place)
        self.layout_trip_details.addRow(QLabel(" Loading Machine:"), self.loading_machine)
        self.layout_trip_details.addRow(QLabel(" Unloading Place:"), self.unloading_place)
        self.layout_trip_details.addRow(QLabel(" Unloading Site:"), self.unloading_site)

        #purchase details
        label2 = QLabel(" Purchase Quantity:")
        label2.setFixedWidth(width)
        self.layout_purchase_details.addRow(label2, self.purchase_quantity)
        self.layout_purchase_details.addRow(QLabel(" Purchase Rate:"), self.purchase_rate)
        self.layout_purchase_details.addRow(QLabel(" Amount Purchase:"), self.amount_purchase)		#purchaseQuanty * Purchase rate
        self.layout_purchase_details.addRow(QLabel(" GST Bill Amount:"), self.gst_bill_amount)
        self.layout_purchase_details.addRow(QLabel(" GST Bill No:"), self.gst_bill_number)
        self.layout_purchase_details.addRow(QLabel(" Total Amount Purchase:"), self.total_amount_purchase)		#amount purchase + gst bill amount

        
        #sale details
        label3 = QLabel(" Sale Quantity:")
        label3.setFixedWidth(width)
        self.layout_sale_details.addRow(label3, self.sale_quantity)
        self.layout_sale_details.addRow(QLabel(" Sale Price:"), self.sale_price)	
        self.layout_sale_details.addRow(QLabel(" Amount Sale:"), self.amount_sale)	#sale_quanity*sale_price
        self.layout_sale_details.addRow(QLabel(" Discount"), self.discount)
        self.layout_sale_details.addRow(QLabel(" Total Amount Sale:"), self.total_amount_sale)	#amount_sale-disount

        #expenses details
        label4 = QLabel(" Labour:")
        label4.setFixedWidth(width)
        self.layout_expense_details.addRow(label4, self.labour)
        self.layout_expense_details.addRow(QLabel(" Dalal Commision:"), self.dalal_commision)
        self.layout_expense_details.addRow(QLabel(" Driver Commision:"), self.driver_commision)
        self.layout_expense_details.addRow(QLabel(" Toll Tax:"), self.toll_tax)
        self.layout_expense_details.addRow(QLabel(" CNG/Diesel 1:"), self.cng_diesel_1)
        self.layout_expense_details.addRow(QLabel(" CNG/Diesel 2:"), self.cng_diesel_2)
        self.layout_expense_details.addRow(QLabel(" Police:"), self.police)
        self.layout_expense_details.addRow(QLabel(" Tyre Fitting Puncture:"), self.tyre_fitting_puncture)
        self.layout_expense_details.addRow(QLabel(" Air Grease Filter:"), self.air_grease_filter)
        self.layout_expense_details.addRow(QLabel(" Others:"), self.others)
        self.layout_expense_details.addRow(QLabel(" Remarks:"), self.expense_remarks)
        self.layout_expense_details.addRow(QLabel(" Total Expense Amount:"), self.total_expense_amount)		#all expenses including other excluding remarks
        
        #vehicle breakdown details
        label5 = QLabel(" Work Type:")
        label5.setFixedWidth(width)
        self.layout_breakdown_details.addRow(label5, self.work_type)
        self.layout_breakdown_details.addRow(QLabel(" Workshop/Dealer:"), self.workshop_dealer)

        
        for i in range(self.no_of_repair):
        	self.layout_breakdown_details.addRow(QLabel(" Mechanic Name "+str(i+1)+":"), self.mechanic_name_list[i])
        	self.layout_breakdown_details.addRow(QLabel(" Labour Charge "+str(i+1)+":"), self.labour_charge_list[i])
        	self.layout_breakdown_details.addRow(QLabel(" Payment Status "+str(i+1)+":"), self.payment_status_list[i])
        

        self.layout_breakdown_details.addRow(QLabel(" Spare Parts Dealer:"), self.spare_parts_dealer)
        self.layout_breakdown_details.addRow(QLabel(" Spare Parts Cost:"), self.spare_parts_cost)
        self.layout_breakdown_details.addRow(QLabel(" Spare Parts Cost Status:"), self.spare_parts_cost_status)
        #spare_parts_cost_status
        self.layout_breakdown_details.addRow(QLabel(" GST Spare Part:"), self.gst_spare_part)
        self.layout_breakdown_details.addRow(QLabel(" GST Labour:"), self.gst_labour)
        self.layout_breakdown_details.addRow(QLabel(" Remarks:"), self.breakdown_remarks)
        self.layout_breakdown_details.addRow(QLabel(" Amount Paid By Driver:"), self.breakdown_amount_paid_by_driver)
        self.layout_breakdown_details.addRow(QLabel(" Amount Paid By Owner:"), self.breakdown_amount_paid_by_owner)
        self.layout_breakdown_details.addRow(QLabel(" Amount Unpaid:"), self.breakdown_amount_unpaid)


        #driver details
        label6 = QLabel(" Driver Name:")
        label6.setFixedWidth(width)
        self.layout_driver_details.addRow(label6, self.driver_name)
        self.layout_driver_details.addRow(QLabel(" Royality:"), self.royality)
        self.layout_driver_details.addRow(QLabel(" Payment Deposit:"), self.payment_deposit_by_driver)
        self.layout_driver_details.addRow(QLabel(" Balance Forwarded:"), self.balance_forward_in_driver_account)	#extacted from previous trip of same vehicle
        self.layout_driver_details.addRow(QLabel(" Balance Of Stock:"), self.balance_of_stock)	#royality + balance_forward + total_amout_sale
        self.layout_driver_details.addRow(QLabel(" In Hand Cash:"), self.in_hand_cash)			#balance of _stock - payment_deposit_by_driver
        self.layout_driver_details.addRow(QLabel(" Total Expense Paid By Driver:"), self.total_expense_paid_by_driver)	#total_amount_purchase + total_trip_expense + total_breakdown_paid_by_driver
        self.layout_driver_details.addRow(QLabel(" Total Profit Of Trip:"), self.total_profit_of_trip)	#total_ampunt_sale - total_expense_paid_by_driver
        self.layout_driver_details.addRow(QLabel(" Royality Given For Next Trip:"), self.royality_given_for_next_trip)	
        self.layout_driver_details.addRow(QLabel(" Balance Forward For Next Trip:"), self.balance_forward_for_next_trip)	#inhand_cash + Royality_given_for_next_trip




        self.clear()
Beispiel #11
0
def interpret(f2_system, filename, perimeters, batch):
    send = send_data.SendData()
    window.get_window()
    with open(filename, 'r') as script:
        for line in script:
            #time.sleep(.1)
            cmd, data = line.split('\t')
            data = data.strip()
            cmd = cmd.strip().lower()
            if cmd == "send":
                send.send(data)
            elif cmd == "go_to":
                if data in locations:
                    locations[data]()
            elif cmd == "go_to_date":
                if data in locations:
                    locations[data](perimeters['date'])
            elif cmd == "perimeter_send":
                if data in perimeters:
                    send.send(perimeters[data])
            elif cmd == "perimeter_send_exact":
                if data in perimeters:
                    send.send_exact(perimeters[data])
            elif cmd == "batch":
                batch_file = batch_process[data]
                for b in batch:
                    interpret(f2_system, batch_file, b, None)
            elif cmd == "verify_screen":
                time.sleep(.5)
                data = ast.literal_eval(data)
                if not navigation.verify(data):
                    print("no")
                    return False
                else:
                    print("yes")
            elif cmd == 'sleep':
                print(11)
                time.sleep(float(data))
            elif cmd == 'perimeter_copy_paste':
                time.sleep(1)
                clipboard.set_clipbaord(perimeters[data])
                send.send('%v')
            elif cmd == "multi_paged":
                left, right, target = data.split('-')
                left = int(left)
                right = int(right)
                send.send('{HOME 3}')
                time.sleep(.3)
                next_page = parse.process_scene(
                    window.get_window())[left:right]
                pages = [next_page]
                while True:
                    send.send('{PGDN}')
                    time.sleep(.3)
                    next_page = parse.process_scene(
                        window.get_window())[left:right]
                    if next_page in pages:
                        break
                    else:
                        pages.append(next_page)
                send.send('{HOME 3}')
                index = 0
                for page in pages:

                    for line in page:
                        if perimeters[target] in line:
                            send.send('{DOWN %s}' % index)
                            print(index)
                            return None
                        index += 1
                time.sleep(0.1)
            elif cmd == "multi_paged_2":
                left, right, target1, target2 = data.split('-')
                left = int(left)
                right = int(right)
                print(perimeters[target1])
                print(perimeters[target2])
                send.send('{HOME 3}')
                time.sleep(.3)
                next_page = parse.process_scene(
                    window.get_window())[left:right]
                pages = [next_page]
                while True:
                    send.send('{PGDN}')
                    time.sleep(.3)
                    next_page = parse.process_scene(
                        window.get_window())[left:right]
                    if next_page in pages:
                        break
                    else:
                        pages.append(next_page)
                send.send('{HOME 3}')
                index = 0
                breakout = False
                for page in pages:

                    for line in page:
                        if perimeters[target1] in line and perimeters[
                                target2] in line:
                            print(line)
                            send.send('{DOWN %s}' % index)
                            breakout = True
                            break
                        if breakout:
                            break
                        index += 1
            elif cmd == "if_not":
                window.get_window()
                target, command = data.split('-')
                if perimeters[target] not in window.get_window():
                    interpret(f2_system, command, perimeters, batch)
            elif cmd == "if_not_else_literal":
                window.get_window()
                target, command1, command2 = data.split('-')
                print(command2)
                if target not in window.get_window():
                    interpret(f2_system, command1, perimeters, batch)
                else:
                    interpret(f2_system, command2, perimeters, batch)

            elif cmd == "run_script":
                interpret(f2_system, data, perimeters, batch)
            elif cmd == 'if_not_insert':
                if data not in window.get_window():
                    print(data)
                    send.send('{INSERT}')
            elif cmd == "if_not_same_line":
                lines = parse.process_scene(window.get_window())

                target1, target2, command = data.split('-')
                match = False
                for line in lines:
                    if perimeters[target1] in line and perimeters[
                            target2] in line:
                        match = True
                        break
                if not match:
                    interpret(f2_system, command, perimeters, batch)
            elif cmd == "go_to_menu":
                command_order = data.split('-')
                navigation.to_menu(command_order)
                print("done")
            elif cmd == "update_assortment":
                database.get_list(perimeters[data])
            elif cmd == "add_to_supplier":
                supplier, assortment = data.split('-')
                database.add_to_supplier(perimeters[supplier],
                                         perimeters[assortment])