Exemplo n.º 1
0
    def time_to_move(self):

        now = functions.time_now()

        if now == self.move_time:
            self.move_time = (now + 1) % 60
            return True
        else:
            return False
Exemplo n.º 2
0
    def update_fuel(self, title, vehicle=None, record=None):
        '''
        Create or update a fuel record
        '''
        print('\n{} Fuel Record for {}:'.format(title, vehicle['reg_no']))
        last = None

        # are we adding a new one or updating an old one?
        if (record == None):
            # adding new, so get the previous value.
            last = FN.last_fuel(vehicle)
            record = FN.frec.copy()
            # set reg for record
            record['vehicle_id'] = vehicle['vehicle_id']
            record['date'] = FN.time_now()

        value = input('Date ({}):'.format(FN.to_date(record['date'])))
        if value:
            record['date'] = FN.to_seconds(value)

        value = input('Litres ({}):'.format(record['litres']))
        if value:
            record['litres'] = float(value)

        value = input('Price per Litre ({}):'.format(record['ppl']))
        if value:
            record['ppl'] = float(value)

        value = input('Cost ({}):'.format(record['cost']))
        if value:
            record['cost'] = float(value)

        value = input('Odometer ({}):'.format(record['odo']))
        if value:
            record['odo'] = int(value)

        calc_trip = record['trip'] 
        if last:
            calc_trip = record['odo'] - last['odo']
        trip = input('Trip ({0}):'.format(calc_trip))
        if trip:
            record['trip'] = float(trip)
        else:
            record['trip'] = calc_trip

        value = input('Notes ({}):'.format(record['notes']))
        if value:
            record['notes'] = value

        value = input('Fuel Type ({}):'.format(record['fuel_type']))
        if value:
            record['fuel_type'] = value

        mpg = FN.update_fuel(vehicle, record)

        print('\nCalculated MPG: {:.2f}'.format(mpg))
Exemplo n.º 3
0
    def update_service(self, title, vehicle, service=None):
        '''
        Create/update a service record
        '''
        print('\n{} Service Record for {}'.format(title, vehicle['reg_no']))
        if not service:
            service = FN.srec.copy()
            service['vehicle_id']=vehicle['vehicle_id']
            service['date'] = FN.time_now()

        self.query('service', service)
        FN.update_service(service)
Exemplo n.º 4
0
def reply(msg):
    print(msg['Text'])
    if msg['Text'] == 'function':
        function_text = str()
        for i, j in function.items():
            function_text = function_text + i + ': ' + j + '\n'
        msg.user.send(function_text)
        print('发送成功')
    elif msg['Text'] == 'hitokoto':
        content = hitokoto.get_content(url)
        msg.user.send(content)
        print('发送成功')
    elif msg['Text'] == 'weibohot':
        results = weiboHot.get_results()
        now = functions.time_now()['second']
        msg.user.send('下面是' + now + '时的微博热搜:\n')
        msg.user.send('\n'.join(results[0:10]))
        print('发送成功')
    elif msg['Text'] == 'jwcbulletin':
        results = jwc_news.get_results()
        print(results)
        results_text = str()
        for i in results[0:10]:
            results_text = results_text + i[1] + '  ' + i[0] + '\n'
        msg.user.send(results_text)
        print('发送成功')
    elif msg['Text'] == 'wallpaper':
        today = functions.time_now()['day']
        number = wallpaper.get_wallpaper()
        msg.user.send('@img@%s' %
                      './wallpapers/{}_{}.jpg'.format(today, number))
        print('./wallpapers/{} {}.jpg'.format(today, number))
        print('发送成功')
    elif msg['Text'] == 'movie':
        movies = movie.getMovie()
        msg.user.send('\n'.join(movies))
        print('发送成功')
Exemplo n.º 5
0
    def __init__(self):

        self.x = 0
        self.y = 0

        # tekstury

        self.right = 1
        self.img = pygame.image.load('img/enemy_r.png')

        # czas

        self.move_time = (functions.time_now() + 1) % 60

        # kryjówka

        self.shelter = (-1, -1)