コード例 #1
0
ファイル: config.py プロジェクト: buzaidj/mobile-ordering
 def send_error_email(self, error, filename):
     send_client = emails.SendManager(self.config_dict['send_email_info'])
     text = 'There was an error setting up config filename.\nError ' + str(
         error) + '.\nFilename: ' + str(filename)
     send_client.send_email(destination=self.destination,
                            subject='Error',
                            msg_content=text)
コード例 #2
0
 def send_confirmation_email(self, config):
     organization_name = config.config_dict['send_email_info']['organization name']
     send_client = emails.SendManager(config.config_dict['send_email_info'])
     text = 'Hi ' + self.name + ',\n\n'
     text += 'Your ' + self.order_type.lower() + ' of ' + self.order + ' has printed succesfully. '
     text += 'It will be ready at ' + self.pickup_time + '.'
     try:
         send_client.send_email(destination = self.email, subject = organization_name + ' - Order Confirmation', msg_content = text)
     except:
         print('Email not sent')
コード例 #3
0
ファイル: gsheets.py プロジェクト: buzaidj/mobile-ordering
 def __init__(self, config):
     done = False
     while not done:
         try:
             self.client = pygsheets.authorize(
                 service_file='client_secret.json')
             self.sheets = []
             for name, params in config.config_dict['gsheets_info'].items():
                 sheet_name = params['spreadsheet_name']
                 format = params['format']
                 sh = self.client.open(sheet_name).sheet1
                 gsheet = GSheet(name, format, sh)
                 self.sheets.append(gsheet)
             done = True
         except Exception as e:
             email_error = emails.SendManager(
                 config.config_dict['send_email_info'])
             email_error.send_email(config.config_dict['send_email_info']
                                    ['send status emails to'],
                                    subject='Error in initializing sheet',
                                    msg_content=str(e))
             time.sleep(30)
コード例 #4
0
    def refresh_sheets(self, config, printer):
        orders = []
        r = None
        while r == None:
            try:
                for gsheet in self.sheets:
                    gsheet.sheet.refresh()
                    time.sleep(5)
                    format = gsheet.format
                    while gsheet.sheet.cell('A' + str(gsheet.index)).value != '':
                        time.sleep(2)
                        order_dict =  {}
                        s_index = str(gsheet.index)
                        f = True
                        while f:
                            try:
                                if 'day' in gsheet.format:
                                    day = gsheet.sheet.cell(format['day'] + s_index).value.lower()
                                    for x in config.day_params:
                                        order_dict[x] = gsheet.sheet.cell(format[day + '_' + x] + s_index).value
                                        time.sleep(2)
                                    for x in config.non_day_params:
                                        order_dict[x] = gsheet.sheet.cell(format[x] + s_index).value
                                        time.sleep(2)
                                else:
                                    for x in config.params:
                                        order_dict[x] = gsheet.sheet.cell(format[x] + s_index).value
                                        time.sleep(2)
                                order_dict['order_type'] = gsheet.name.capitalize() + ' Order'
                                order_dict['order_number'] = gsheet.index % 100
                                orders.append(order_dict)

                                order = Order(order_dict)
                                printer.print_ticket(order)
                                order.send_confirmation_email(config)

                                f = False
                            except Exception as e:
                                try:
                                    print('ERROR')
                                    email_error = emails.SendManager(config.config_dict['send_email_info'])
                                    email_error.send_email(config.config_dict['send_email_info']['send status emails to'], subject = 'Error in getting sheet cells', msg_content = str(e))
                                    time.sleep(5)
                                except:
                                    time.sleep(5)


                        time.sleep(1)
                        print('Reading')
                        gsheet.index += 1

                    gsheet.update_index()
                r = orders
            except Exception as e:
                print(e)
                try:
                    email_error = emails.SendManager(config.config_dict['send_email_info'])
                    email_error.send_email(config.config_dict['send_email_info']['send status emails to'], subject = 'Error in refreshing sheet', msg_content = str(e))
                    time.sleep(30)
                except:
                    time.sleep(10)
        return orders
コード例 #5
0
ファイル: config.py プロジェクト: buzaidj/mobile-ordering
 def send_confirmation_email(self, filename):
     send_client = emails.SendManager(self.config_dict['send_email_info'])
     text = str(filename) + ' initalized succesfully'
     send_client.send_email(destination=self.destination,
                            subject='Success',
                            msg_content=text)