def connect(self): options = { 'webdav_hostname': settingsManager.get_webdav_server(), 'webdav_login': settingsManager.get_webdav_username(), 'webdav_password': settingsManager.get_webdav_password() } self.client = wc.Client(options)
def get_client(storage): options = { 'webdav_hostname': storage.url + '/remote.php/dav/files/' + storage.username, 'webdav_login': storage.username, 'webdav_password': storage.password } return wc.Client(options)
def get_client(storage): options = { 'webdav_hostname': storage.url, 'webdav_login': storage.username, 'webdav_password': storage.password, 'webdav_root': '/remote.php/dav/files/' + storage.username } if storage.path != '': options['webdav_root'] = storage.path return wc.Client(options)
def connect(self): options = { 'webdav_hostname': self.url, 'webdav_login': self.username, 'webdav_password': self.password, 'webdav_verbose': True, # This does nothing 'webdav_root': self.root } logger.info(f'Connecting to {self.url} with user {self.username}') self.client = wc.Client(options)
def connect(self, credential: Credential): opts = {"webdav_hostname": credential.url, "webdav_login": credential.login, "webdav_password": credential.password} try: self.__client = wclient.Client(opts) Log.Info("Connection established with the remote storage") except: Log.Error("Failed to connet to your webdav storage. Verify your configuration")
def main(build_context, user, passw): email = user + '@uni-muenster.de' options = { 'webdav_hostname': "https://uni-muenster.sciebo.de", 'webdav_root': "remote.php/webdav/", 'webdav_login': email, 'webdav_password': passw, } client = wc.Client(options) client.download_sync(remote_path=build_context, local_path='/temp')
def main(build_context, user, token): webdav_root = "owncloud/remote.php/dav/files/" + user + "/" options = { 'webdav_hostname': "http://rds-ps-oc.uni-muenster.de", 'webdav_root': webdav_root, 'webdav_token': token, } client = wc.Client(options) client.download_sync(remote_path=build_context, local_path='/temp')
def __init__(self, url, login=None, password=None, root=None): self.url = url self.root = root super(WebDAVFS, self).__init__() options = { 'webdav_hostname': self.url, 'webdav_login': login, 'webdav_password': password, 'root': self.root } self.client = wc.Client(options)
def _make_client(self): auth = request.authorization hostname = self.config['webdav_hostname'] username = self.config.get('webdav_login', auth.username) password = self.config.get('webdav_password', auth.password) options = {'webdav_hostname': hostname, 'webdav_login': username, 'webdav_password': password} return wd_client.Client(options)
def __init__(self, url, login=None, password=None, root=None, cache_maxsize=10000, cache_ttl=60): self.url = url self.root = root super(WebDAVFS, self).__init__() options = { 'webdav_hostname': self.url, 'webdav_login': login, 'webdav_password': password, 'root': self.root } self.info_cache = TTLCache(maxsize=cache_maxsize, ttl=cache_ttl) self.client = wc.Client(options)
def retrieve_password(self, username): if request.authorization.password is not None: client = wd_client.Client({ 'webdav_hostname': self.config['webdav_hostname'], 'webdav_login': username, 'webdav_password': request.authorization.password }) if client.check(self.config['path'].format(username=username)): return request.authorization.password return None
def _setup_webdav_client(server, root, username, password): """Configures and checks the webdav client.""" # setup webdav connection webdav_options = dict( webdav_hostname=server, webdav_root=root, webdav_login=username, webdav_password=password, ) from webdav3 import client as webdav retval = webdav.Client(webdav_options) assert retval.valid() return retval
def _in(json_in): dest_dir = sys.argv[1] timestamp = json_in.get("version", {}).get("from") watched_folder = json_in.get("source").get("watch_folder") options = json_in.get("source") client = wc.Client(options) picture_list = client.list(watched_folder)[1:] new_pix = list( filter( lambda p: get_timestamp(client, watched_folder + p) > int( timestamp), picture_list)) with open(os.path.join(dest_dir, "pix.json"), "w") as outfile: json.dump(new_pix, outfile) print(json.dumps(json_in))
def record(args): settings = read_settings(args) streamurl = '' global verboseprint verboseprint = print if args.verbose else lambda *a, **k: None try: streamurl = settings['STATIONS'][args.station] except KeyError: print('Unkown station name: ' + args.station) sys.exit() if streamurl.endswith('.m3u'): verboseprint('Seems to be an M3U playlist. Trying to parse...') with urllib.request.urlopen(streamurl) as remotefile: for line in remotefile: if not line.decode('utf-8').startswith('#') and len(line) > 1: tmpstr = line.decode('utf-8') break streamurl = tmpstr verboseprint('stream url: ' + streamurl) options = { 'webdav_hostname': settings['WEBDAV']['url'], 'webdav_login': settings['WEBDAV']['user'], 'webdav_password': settings['WEBDAV']['password'] } webdav = wc.Client(options) webdav.free() conn = urllib.request.urlopen(streamurl) remote_path = get_remote_path(conn.getheader('Content-Type'), settings['WEBDAV']['remote_dir'], args) with tempfile.NamedTemporaryFile() as target: verboseprint('tempfile: ' + target.name) verboseprint('Recording ' + args.station + '...') timeout = args.duration * 60 timeout_start = time.time() while time.time() < timeout_start + timeout: target.write(conn.read(1024)) verboseprint('uploading file to ' + remote_path) webdav.upload(remote_path, target.name)
def _check(json_in): watched_folder = json_in.get("source").get("watch_folder") options = json_in.get("source") client = wc.Client(options) previous_version = json_in.get("version") if previous_version: previous_version = int(previous_version.get("version")) else: previous_version = 0 version = None if client.check(watched_folder): version = get_timestamp(client, watched_folder) json_data = [] if version > previous_version: json_data.append({ 'version': str(version), 'from': str(previous_version) }) print(json.dumps(json_data))
def download_import_file(): client = wc.Client(options) client.download_file(getenv("IMPORT_FILE"), _IMPORT_FILE)
def upload_export_file(): if path.isfile(_EXPORT_FILE): client = wc.Client(options) client.upload_sync(remote_path=getenv("EXPORT_FILE"), local_path=_EXPORT_FILE)