def gen(self):
     self.draw.rectangle(self.rectXY, self.bgColor)
     self.draw.multiline_text((self.width * self.w + self.padding,
                               self.height * self.h + self.padding),
                              self.text,
                              self.fontColor,
                              font=self.font)
     self.baseImg.save(self.name, quality=90)
     # print('File successfully generated.')
     folderID = open('drive.txt', 'r').read()
     if folderID != 'False\n' and not self.d:
         main()
         upload(self.name, self.mime)
         os.remove(self.name)
Example #2
0
def upload(source, destination):
    global cur_path
    if os.path.isdir(destination):

        folder_id = directory[destination]
        print(destination)
        if os.path.isfile(source):
            filename = source[source.rfind('/') + 1:]
            print(filename)
            drive.upload(source, filename, folder_id)
        else:
            print("error: invalid source")
    else:
        print("error: invalid destination")
def show_upload_options(itens):
    print('\nDo you want to upload any item?\n')
    print('[0] No')
    for i in range(0, len(itens)):
        print('[{}] {}'.format(i + 1, itens[i]))
    print('[{}] All'.format(len(itens) + 1))
    choice = input('\nOption: ')
    if choice == '0':  #None
        sys.exit()
    if choice.find(',') == -1 and int(choice) == len(itens) + 1:  #All
        index = 1
        for item in itens:
            print('\n{} of {}'.format(index, len(itens)))
            if item.find('.') != -1:  #is file
                drive.upload(item)
            else:  #is folder
                path = './' + item
                print('Compressing {}'.format(item))
                zip_file = compactor.build_zip(path)
                drive.upload(zip_file, True)
            index += 1
        sys.exit()
    #Custom
    choices = choice.split(',')
    index = 1
    for i in range(0, len(choices)):
        print('\n{} of {}'.format(index, len(choices)))
        if itens[int(choices[i]) - 1].find('.') != -1:  #is file
            drive.upload(itens[int(choices[i]) - 1])
        else:
            path = './' + itens[int(choices[i]) - 1]
            print('Compressing {}'.format(itens[int(choices[i]) - 1]))
            zip_file = compactor.build_zip(path)
            drive.upload(zip_file, True)
        index += 1
    sys.exit()
Example #4
0
 def upload_to_drive(self):
     drive.main()
     drive.upload(self.file_name, self.file_path, 'text/txt')
     self.status_bar['text'] = 'Uploaded!'
     self.set_status_bar_color(bg='green', fg='white')
Example #5
0
        camera.start_preview()
        sleep(light_sensing)
        f_path = 'goldfish_%s.jpg' % num  # '/home/pi/Desktop/goldfish_%s.jpg'
        f_name = f_path.split('/')[-1]
        # Take a photo
        camera.capture(f_path)
        camera.stop_preview()

        # Analyze the photo
        letter, new_f_name, new_f_path = analyze(f_path, num)
        # Write letter to file
        # TODO: Display on the screen
        if letter and letter != last_letter:
            # Upload file to Google Drive
            # Only write the letter and upload the photo when location changes
            drive.upload(f_name, f_path, 'image/jpeg')
            drive.upload(new_f_name, new_f_path, 'image/jpeg')
            write(letter)
            last_letter = letter

        sleep(photo_freq - light_sensing - wait_gap - 1)  # Take only one photo every minute

        # Remove local photo
        if os.path.exists(f_path):
            os.remove(new_f_path)
            os.remove(f_path)
        else:
            print("PATH NOT EXISTS ERROR (remove)")

        # Now wait for users to press a key, if they want to terminate
        signal.alarm(wait_gap)
def upload(is_handle):
    file = 'archives/%s.zip' % is_handle
    print('Uploading %s' % file)
    return drive.upload(file, title=is_handle + '.zip')
Example #7
0
def main():
    draw.what_to_draw()
    draw.draw()
    drive.upload(draw.get_files())