def __init__(self, args): for key, value in vars(args).items(): setattr(self, key, value) auth = GDAuth() creds = auth.get_credentials() self.auth_user = creds.id_token.get("email", None) if creds is None: raise Exception("Failed to retrieve credentials") self.http = auth.get_authorized_http() base = GDBase() self.service = base.get_drive_service(self.http) self.root = base.get_root() self.id = base.get_id_from_url(self.id) # get title and check if folder, is_folder and title are available now self.is_folder = None self.title = None self.get_file_meta() self.copy_dir_stat = { "total":0}
def __init__(self, args): for key, value in vars(args).items(): setattr(self, key, value) auth = GDAuth() creds = auth.get_credentials() self.auth_user = creds.id_token.get("email", None) if creds is None: raise Exception("Failed to retrieve credentials") self.http = auth.get_authorized_http() base = GDBase() self.service = base.get_drive_service(self.http) self.root = base.get_root()
def __init__( self, source_file, mime_type, target_type, folder_id, title, description, location_column, latlng_column, permission, csv_column_define): logger.debug("source_file=%s, mime_type=%s, target_type=%s" % (source_file, mime_type, target_type)) self.source_file = source_file self.mime_type = mime_type self.target_type = target_type self.folder_id = folder_id self.title = title self.description = description self.location_column = location_column self.latlng_column = latlng_column self.permission = permission self.csv_column_define = csv_column_define self.file_id = None self.ft_headers = None self.csv_latlng_suffix = "_latlng_%04x.csv" % random.getrandbits(16) # base auth = GDAuth() creds = auth.get_credentials() self.auth_user = creds.id_token.get("email",None) if creds == None: raise Exception("Failed to retrieve credentials") self.http = auth.get_authorized_http() base = GDBase() self.service = base.get_drive_service(self.http) self.root = base.get_root() # ft service if target_type == "ft": self.ft_service = base.get_ft_service(self.http)
def __init__(self, file_id, format, save_as): # base auth = GDAuth() self.credentials = auth.get_credentials() if self.credentials is None: raise Exception("Failed to retrieve credentials") self.http = auth.get_authorized_http() base = GDBase() self.service = base.get_drive_service(self.http) self.file_id = base.get_id_from_url(file_id) self.format = format if save_as is None: self.save_as = None else: self.save_as = os.path.abspath(save_as)
def __init__(self, args): logger.debug(vars(args)) for key, value in vars(args).items(): setattr(self, key, value) self.mime_type = "application/vnd.google-apps.folder" auth = GDAuth() creds = auth.get_credentials() self.auth_user = creds.id_token.get("email", None) if creds is None: raise Exception("Failed to retrieve credentials") self.http = auth.get_authorized_http() base = GDBase() self.service = base.get_drive_service(self.http) self.root = base.get_root() logger.debug(self)
def __init__(self, args): for key, value in vars(args).items(): setattr(self, key, value) auth = GDAuth() creds = auth.get_credentials() self.auth_user = creds.id_token.get("email", None) if creds is None: raise Exception("Failed to retrieve credentials") self.http = auth.get_authorized_http() base = GDBase() self.service = base.get_drive_service(self.http) self.root = base.get_root() self.folder_id = base.get_id_from_url(self.folder_id) # get title response = self.service.files().get(fileId=self.folder_id).execute() logger.debug(response) if self.new_title: self.title_folder = self.new_title else: self.title_folder = response["title"] if self.parent_id == None: parents = response.get("parents",None) for p in parents: if p.get("isRoot", False): self.parent_id = p["id"] # statistics self.stats = [] # tree self.tree = OrderedDict() self.tree["root"] = {}
choices=DEBUG_LEVEL, default=DEBUG_LEVEL[-1], help='define the debug level') args = arg_parser.parse_args() logger.debug(args) # post-processing of argument parsing if (getattr(args, 'client_id', None) == None) != ( getattr(args, 'client_secret', None) == None): arg_parser.error("must supply --client_id with --client_secret") # set debug devel logger.setLevel(getattr(logging, args.debug.upper())) if args.redirect_uri == 'oob': if_oob = True else: if_oob = False auth = GDAuth(args.secret_file, if_oob) result = auth.run() if result is None: print("Failed to pass OAuth2 authentication") sys.exit(1) else: print("The OAuth2 authentication has completed") sys.exit(0)