Created
January 6, 2020 10:18
-
-
Save saippuakauppias/0680b0bcedef5c6689459b055fe3b09a to your computer and use it in GitHub Desktop.
Yandex.Disk upload file example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import yadisk # https://pypi.org/project/yadisk/ | |
def check_auth(y): | |
if y.check_token(): | |
print("Token valid") | |
else: | |
raise Exception('Token invalid!') | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--auth_appid', type=str, default='') | |
parser.add_argument('--auth_appsecret', type=str, default='') | |
parser.add_argument('--auth_apptoken', type=str, default='') | |
parser.add_argument('--path_from', type=str, default='') | |
parser.add_argument('--path_to', type=str, default='') | |
args = parser.parse_args() | |
y = yadisk.YaDisk(args.auth_appid, args.auth_appsecret, args.auth_apptoken) | |
check_auth(y) | |
y.upload(args.path_from, args.path_to, overwrite=False) | |
print('Done') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment