该drive.mount()
函数的当前代码位于https://github.com/googlecolab/colabtools/blob/fe964e0e046c12394bae732eaaeda478bc5fa350/google/colab/drive.py
它是位于 /opt/google/drive/drive 的驱动器可执行文件的包装器。我发现可执行文件接受一个authorize_new_user
可用于强制重新身份验证的标志。
将 drive.py 文件的内容复制并粘贴到您的笔记本中。然后将第 189 行的当前调用修改为d.sendline()
如下所示(注意添加authorize_new_user
标志):
d.sendline(
('cat {fifo} | head -1 | ( {d}/drive '
'--features=max_parallel_push_task_instances:10,'
'max_operation_batch_size:15,opendir_timeout_ms:{timeout_ms},'
'virtual_folders:true '
'--authorize_new_user=True '
'--inet_family=' + inet_family + ' ' + metadata_auth_arg +
'--preferences=trusted_root_certs_file_path:'
'{d}/roots.pem,mount_point_path:{mnt} --console_auth 2>&1 '
'| grep --line-buffered -E "{oauth_prompt}|{problem_and_stopped}"; '
'echo "{drive_exited}"; ) &').format(
d=drive_dir,
timeout_ms=timeout_ms,
mnt=mountpoint,
fifo=fifo,
oauth_prompt=oauth_prompt,
problem_and_stopped=problem_and_stopped,
drive_exited=drive_exited))
调用drive
模块版本flush_and_unmount()
或您粘贴的模块版本,然后调用您的版本mount()
以其他用户身份登录!