コード例 #1
0
  upload_file_mimetype = mimetype_upload_file[0]

  if mimetype_upload_file is None:
    print "could not get mimetype for upload file"
    sys.exit()

  upload_file_title =  os.path.basename(upload_file_path)
  
  
  config_file = open(config_file_path, 'r')
  config = json.loads(config_file.read())

  
  drive_service = helper.createDriveService(config)
  print helper.coloured_output("Authentication is sucessful" , 'green')
  print helper.print_about( drive_service )
  print helper.coloured_output("Uploading file to your google drive" , 'yellow')

  file_result = helper.insert_file( drive_service, config, upload_file_path, upload_file_title,upload_file_mimetype  )
  
  print helper.coloured_output("Uploaded new file done" , 'green')
  #print file_result

  print helper.coloured_output("Getting list of children files" , 'yellow')
  children_files = helper.retrieve_all_files( drive_service, config['backup_folder_id'] )
  # print "children_files", children_files
  #print children_files
  print "This folder have {0} files".format( str(len(children_files)) )

  if len( children_files ) > config['max_file_in_folder']:
コード例 #2
0
    #print(type(mimetype_upload_file))

    upload_file_mimetype = mimetype_upload_file[0]

    if upload_file_mimetype is None:
        print("could not get mimetype for upload file - using the default")
        upload_file_mimetype = 'application/octet-stream'

    upload_file_title = os.path.basename(upload_file_path)

    with open(config_file_path, 'r') as config_file:
        config = json.loads(config_file.read())

    drive_service = helper.createDriveService(config)
    print(helper.coloured_output("Authentication is sucessful", 'green'))
    print(helper.print_about(drive_service))
    print(
        helper.coloured_output("Uploading file to your google drive",
                               'yellow'))

    file_result = helper.insert_file(drive_service, config, upload_file_path,
                                     upload_file_title, upload_file_mimetype)

    print(helper.coloured_output("Uploaded new file done", 'green'))
    #print(file_result

    print(helper.coloured_output("Getting list of children files", 'yellow'))
    children_files = helper.retrieve_all_files(drive_service,
                                               config['backup_folder_id'])
    # print("children_files", children_files)
コード例 #3
0
try:
    if __name__ != '__main__':
        print "not allow"
        sys.exit()

    current_file = os.path.realpath(__file__)
    current_path = os.path.dirname(current_file)

    os.chdir(current_path)

    print sys.argv

    if len(sys.argv) != 3:
        print helper.coloured_output(
            "wrong argv python restore.py config_file_path restore_path",
            'red')
        print helper.coloured_output(
            "Example: python restore.py configs/abc.com.json /var/www/",
            'blue')
        sys.exit()

    config_file_path = sys.argv[1]
    restore_path = sys.argv[2]

    if os.path.isfile(config_file_path) is False:
        print "not found config file: " + config_file_path
        sys.exit()

    if os.path.exists(current_path) is False:
        print "not found restore path: " + config_file_path
コード例 #4
0
import helper

try:
  if __name__ != '__main__':
    print "not allow"
    sys.exit()

  current_file = os.path.realpath(__file__)
  current_path = os.path.dirname(current_file)

  os.chdir(current_path)

  print sys.argv

  if len(sys.argv) != 3:
    print helper.coloured_output("wrong argv python restore.py config_file_path restore_path" , 'red')
    print helper.coloured_output("Example: python restore.py configs/abc.com.json /var/www/" , 'blue')
    sys.exit()

  config_file_path = sys.argv[1]
  restore_path = sys.argv[2]

  if  os.path.isfile(config_file_path) is False:
    print "not found config file: "+config_file_path
    sys.exit()

  if os.path.exists(current_path) is False:
    print "not found restore path: "+config_file_path
    print "make sure this's a folder"
    sys.exit()