def upload(_login, _password, _server_dir, _file): if os.path.isfile(_file): disk = YaDisk(_login, _password) disk.upload(_file, _server_dir + '/' + os.path.basename(_file)) link = disk.publish_doc(_server_dir + '/' + os.path.basename(_file)) print link else: print "Error: file-path is bad" return 1
if ext.lower() in ( '.gif', '.jpg', '.png', ): remote_folder = 'FotoSite' if os.getenv('EGAX_DEBUG') == '1': remote_folder = 'Foto' remote_file = name remote_path = E_OS('/{folder}/{file}'.format(folder=remote_folder, file=remote_file)) yadisk.upload(remote_file, remote_path) url = yadisk.publish_doc(remote_path) param = [] param += [("album", E_OS(os.path.basename(cwd)))] param += [("thumb_url", url)] param += [("title", E_OS(fname))] param += [("memberonly", memberonly)] param += [("user", user)] print os.path.basename(cwd), name, url register_openers() datagen, headers = multipart_encode(param) url = "http://egaxegax.appspot.com/photos/add"