code stringlengths 1 18.2k |
|---|
def pack(cls, data): '''Pack the provided data into a Response''' return struct.pack('>ll', len(data) + 4, cls.FRAME_TYPE) + data |
def fin(self): '''Indicate that this message is finished processing''' self.connection.fin(self.id) self.processed = True |
def req(self, timeout): '''Re-queue a message''' self.connection.req(self.id, timeout) self.processed = True |
def handle(self): '''Make sure this message gets either 'fin' or 'req'd''' try: yield self except: # Requeue the message and raise the original exception typ, value, trace = sys.exc_info() if not self.processed: try: self.req(self.delay()) except socket.error: self.connection.close() raise typ, value, trace else: if no... |
def find(cls, name): '''Find the exception class by name''' if not cls.mapping: # pragma: no branch for _, obj in inspect.getmembers(exceptions): if inspect.isclass(obj): if issubclass(obj, exceptions.NSQException): # pragma: no branch if hasattr(obj, 'name'): cls.mapping[obj.name] = obj klass = cls.mapping.get(name) i... |
def exception(self): '''Return an instance of the corresponding exception''' code, _, message = self.data.partition(' ') return self.find(code)(message) |
def parse_gdb_version(line): r"""Parse the gdb version from the gdb header. From GNU coding standards: the version starts after the last space of the first line. >>> DOCTEST_GDB_VERSIONS = [ ... r'~"GNU gdb (GDB) 7.5.1\n"', ... r'~"GNU gdb (Sourcery CodeBench Lite 2011.09-69) 7.2.50.20100908-cvs\n"', ... r'~"GNU gdb (G... |
in DOCTEST_GDB_VERSIONS: ... print(parse_gdb_version(header)) 7.5.1 7.2.50.20100908 7.5.1 7.6 7.6.1 """ if line.startswith('~"') and line.endswith(r'\n"'): version = line[2:-3].rsplit(' ', 1) if len(version) == 2: # Strip after first non digit or '.' character. Allow for linux # Suse non conformant implementation that ... |
def spawn_gdb(pid, address=DFLT_ADDRESS, gdb='gdb', verbose=False, ctx=None, proc_iut=None): """Spawn gdb and attach to a process.""" parent, child = socket.socketpair() proc = Popen([gdb, '--interpreter=mi', '-nx'], bufsize=0, stdin=child, stdout=child, stderr=STDOUT) child.close() connections = {} gdb = GdbSocket(ctx... |
def attach_loop(argv): """Spawn the process, then repeatedly attach to the process.""" # Check if the pdbhandler module is built into python. p = Popen((sys.executable, '-X', 'pdbhandler', '-c', 'import pdbhandler; pdbhandler.get_handler().host'), stdout=PIPE, stderr=STDOUT) p.wait() use_xoption = True if p.returncode ... |
SIGUSR1. args.extend(['-X', 'pdbhandler=localhost 7935 %d' % signal.SIGUSR2]) args.extend(argv) proc = Popen(args) else: args.extend(argv) proc = Popen(args) # Repeatedly attach to the process using the '-X' python option or gdb. ctx = Context() error = None time.sleep(.5 + random.random()) while not error and proc.pol... |
socket.SOCK_STREAM) connect_process(asock, ctx, proc) asyncore.loop(map=connections) else: error = spawn_gdb(proc.pid, ctx=ctx, proc_iut=proc) time.sleep(random.random()) if error and gdb_terminated(error): error = None if proc.poll() is None: proc.terminate() else: print('pdb-attach: program under test return code:', ... |
def skip(self): """Skip this py-pdb command to avoid attaching within the same loop.""" line = self.line self.line = '' # 'line' is the statement line of the previous py-pdb command. if line in self.lines: if not self.skipping: self.skipping = True printflush('Skipping lines', end='') printflush('.', end='') return Tru... |
def rotate(self, log): """Move the current log to a new file with timestamp and create a new empty log file.""" self.write(log, rotate=True) self.write({}) |
def write(self, log, rotate=False): """Write the output of all finished processes to a compiled log file.""" # Get path for logfile if rotate: timestamp = time.strftime('-%Y%m%d-%H%M') logPath = os.path.join(self.log_dir, 'queue{}.log'.format(timestamp)) else: logPath = os.path.join(self.log_dir, 'queue.log') # Remove ... |
if logentry.get('returncode') is not None: try: # Get returncode color: returncode = logentry['returncode'] if returncode == 0: returncode = Color('{autogreen}' + '{}'.format(returncode) + '{/autogreen}') else: returncode = Color('{autored}' + '{}'.format(returncode) + '{/autored}') # Write command id with returncode a... |
\n'.format(logentry['path'])) # Write times log_file.write('Start: {}, End: {} \n' .format(logentry['start'], logentry['end'])) # Write STDERR if logentry['stderr']: log_file.write(Color('{autored}Stderr output: {/autored}\n ') + logentry['stderr']) # Write STDOUT if len(logentry['stdout']) > 0: log_file.write(Color('{... |
def remove_old(self, max_log_time): """Remove all logs which are older than the specified time.""" files = glob.glob('{}/queue-*'.format(self.log_dir)) files = list(map(lambda x: os.path.basename(x), files)) for log_file in files: # Get time stamp from filename name = os.path.splitext(log_file)[0] timestamp = name.spli... |
= delta.total_seconds() # Delete log file, if the delta is bigger than the specified log time if seconds > int(max_log_time): log_filePath = os.path.join(self.log_dir, log_file) os.remove(log_filePath) |
def wrap(function, *args, **kwargs): '''Wrap a function that returns a request with some exception handling''' try: req = function(*args, **kwargs) logger.debug('Got %s: %s', req.status_code, req.content) if req.status_code == 200: return req else: raise ClientException(req.reason, req.content) except ClientException: ... |
def json_wrap(function, *args, **kwargs): '''Return the json content of a function that returns a request''' try: # Some responses have data = None, but they generally signal a # successful API call as well. response = json.loads(function(*args, **kwargs).content) if 'data' in response: return response['data'] or True ... |
def ok_check(function, *args, **kwargs): '''Ensure that the response body is OK''' req = function(*args, **kwargs) if req.content.lower() != 'ok': raise ClientException(req.content) return req.content |
def get(self, path, *args, **kwargs): '''GET the provided endpoint''' target = self._host.relative(path).utf8 if not isinstance(target, basestring): # on older versions of the `url` library, .utf8 is a method, not a property target = target() params = kwargs.get('params', {}) params.update(self._params) kwargs['params'... |
def decode_resumable_upload_bitmap(bitmap_node, number_of_units): """Decodes bitmap_node to hash of unit_id: is_uploaded bitmap_node -- bitmap node of resumable_upload with 'count' number and 'words' containing array number_of_units -- number of units we are uploading to define the number of bits for bitmap """ bitmap ... |
in range(number_of_units): mask = 1 << unit_id result[unit_id] = (bitmap & mask) == mask return result |
def compute_hash_info(fd, unit_size=None): """Get MediaFireHashInfo structure from the fd, unit_size fd -- file descriptor - expects exclusive access because of seeking unit_size -- size of a single unit Returns MediaFireHashInfo: hi.file -- sha256 of the whole file hi.units -- list of sha256 hashes for each unit """ l... |
file_hash = hashlib.sha256() unit_hash = hashlib.sha256() for chunk in iter(lambda: fd.read(HASH_CHUNK_SIZE_BYTES), b''): file_hash.update(chunk) unit_hash.update(chunk) unit_counter += len(chunk) if unit_size is not None and unit_counter == unit_size: # flush the current unit hash units.append(unit_hash.hexdigest().lo... |
def upload(self, fd, name=None, folder_key=None, filedrop_key=None, path=None, action_on_duplicate=None): """Upload file, returns UploadResult object fd -- file-like object to upload from, expects exclusive access name -- file name folder_key -- folderkey of the target folder path -- path to file relative to folder_key... |
most reliable way fd.seek(0, os.SEEK_END) size = fd.tell() fd.seek(0, os.SEEK_SET) if size > UPLOAD_SIMPLE_LIMIT_BYTES: resumable = True else: resumable = False logger.debug("Calculating checksum") hash_info = compute_hash_info(fd) if hash_info.size != size: # Has the file changed beween computing the hash # and callin... |
self._upload_check(upload_info, resumable) upload_result = None upload_func = None folder_key = check_result.get('folder_key', None) if folder_key is not None: # We know precisely what folder_key to use, drop path upload_info.folder_key = folder_key upload_info.path = None if check_result['hash_exists'] == 'yes': # fil... |
== 'no': # file is already there upload_func = self._upload_none if not upload_func: # different hash or in other folder upload_func = self._upload_instant if not upload_func: if resumable: resumable_upload_info = check_result['resumable_upload'] upload_info.hash_info = compute_hash_info( fd, int(resumable_upload_info[... |
= upload_func(upload_info, check_result) except (RetriableUploadError, MediaFireConnectionError): retries -= 1 logger.exception("%s failed (%d retries left)", upload_func.__name__, retries) # Refresh check_result for next iteration check_result = self._upload_check(upload_info, resumable) except Exception: logger.excep... |
def _poll_upload(self, upload_key, action): """Poll upload until quickkey is found upload_key -- upload_key returned by upload/* functions """ if len(upload_key) != UPLOAD_KEY_LENGTH: # not a regular 11-char-long upload key # There is no API to poll filedrop uploads return UploadResult( action=action, quickkey=None, ha... |
filename=%s," " result=%d", upload_key, int(doupload['status']), doupload['description'], doupload['filename'], int(doupload['result'])) if int(doupload['result']) != 0: break if doupload['fileerror'] != '': # TODO: we may have to handle this a bit more dramatically logger.warning("poll(%s): fileerror=%d", upload_key, ... |
filename=doupload['filename'], size=doupload['size'], created=doupload['created'], revision=doupload['revision'] ) |
def _upload_check(self, upload_info, resumable=False): """Wrapper around upload/check""" return self._api.upload_check( filename=upload_info.name, size=upload_info.size, hash_=upload_info.hash_info.file, folder_key=upload_info.folder_key, filedrop_key=upload_info.filedrop_key, path=upload_info.path, resumable=resumable... |
def _upload_none(self, upload_info, check_result): """Dummy upload function for when we don't actually upload""" return UploadResult( action=None, quickkey=check_result['duplicate_quickkey'], hash_=upload_info.hash_info.file, filename=upload_info.name, size=upload_info.size, created=None, revision=None ) |
def _upload_instant(self, upload_info, _=None): """Instant upload and return quickkey Can be used when the file is already stored somewhere in MediaFire upload_info -- UploadInfo object check_result -- ignored """ result = self._api.upload_instant( upload_info.name, upload_info.size, upload_info.hash_info.file, path=up... |
def _upload_simple(self, upload_info, _=None): """Simple upload and return quickkey Can be used for small files smaller than UPLOAD_SIMPLE_LIMIT_BYTES upload_info -- UploadInfo object check_result -- ignored """ upload_result = self._api.upload_simple( upload_info.fd, upload_info.name, folder_key=upload_info.folder_key... |
def _upload_resumable_unit(self, uu_info): """Upload a single unit and return raw upload/resumable result uu_info -- UploadUnitInfo instance """ # Get actual unit size unit_size = uu_info.fd.len if uu_info.hash_ is None: raise ValueError('UploadUnitInfo.hash_ is now required') return self._api.upload_resumable( uu_info... |
def _upload_resumable_all(self, upload_info, bitmap, number_of_units, unit_size): """Prepare and upload all resumable units and return upload_key upload_info -- UploadInfo object bitmap -- bitmap node of upload/check number_of_units -- number of units requested unit_size -- size of a single upload unit in bytes """ fd ... |
uploaded", unit_id + 1, number_of_units) continue logger.debug("Uploading unit %d/%d", unit_id + 1, number_of_units) offset = unit_id * unit_size with SubsetIO(fd, offset, unit_size) as unit_fd: unit_info = _UploadUnitInfo( upload_info=upload_info, hash_=upload_info.hash_info.units[unit_id], fd=unit_fd, uid=unit_id) up... |
def _upload_resumable(self, upload_info, check_result): """Resumable upload and return quickkey upload_info -- UploadInfo object check_result -- dict of upload/check call result """ resumable_upload = check_result['resumable_upload'] unit_size = int(resumable_upload['unit_size']) number_of_units = int(resumable_upload[... |
resumable_upload['all_units_ready'] == 'yes' bitmap = resumable_upload['bitmap'] while not all_units_ready and retries > 0: upload_key = self._upload_resumable_all(upload_info, bitmap, number_of_units, unit_size) check_result = self._upload_check(upload_info, resumable=True) resumable_upload = check_result['resumable_u... |
polling for status") return self._poll_upload(upload_key, 'upload/resumable') |
def reset(self): """Remove from sys.modules the modules imported by the debuggee.""" if not self.hooked: self.hooked = True sys.path_hooks.append(self) sys.path.insert(0, self.PATH_ENTRY) return for modname in self: if modname in sys.modules: del sys.modules[modname] submods = [] for subm in sys.modules: if subm.starts... |
as # there is no way to distinguish them. for subm in submods: del sys.modules[subm] self[:] = [] |
def get_func_lno(self, funcname): """The first line number of the last defined 'funcname' function.""" class FuncLineno(ast.NodeVisitor): def __init__(self): self.clss = [] def generic_visit(self, node): for child in ast.iter_child_nodes(node): for item in self.visit(child): yield item def visit_ClassDef(self, node): s... |
None: self.functions_firstlno = {} for name, lineno in FuncLineno().visit(self.node): if (name not in self.functions_firstlno or self.functions_firstlno[name] < lineno): self.functions_firstlno[name] = lineno try: return self.functions_firstlno[funcname] except KeyError: raise BdbSourceError('{}: function "{}" not foun... |
def get_actual_bp(self, lineno): """Get the actual breakpoint line number. When an exact match cannot be found in the lnotab expansion of the module code object or one of its subcodes, pick up the next valid statement line number. Return the statement line defined by the tuple (code firstlineno, statement line number) ... |
to 'lineno'. When 'lineno' is the first line number of a subcode, use its first statement line instead. """ def _distance(code, module_level=False): """The shortest distance to the next valid statement.""" subcodes = dict((c.co_firstlineno, c) for c in code.co_consts if isinstance(c, types.CodeType) and not c.co_name.s... |
equal to lineno. That is, find the # index of the first subcode whose first_lno is the first to be # strictly greater than lineno. subcode_dist = None subcodes_flnos = sorted(subcodes) idx = bisect(subcodes_flnos, lineno) if idx != 0: flno = subcodes_flnos[idx-1] subcode_dist = _distance(subcodes[flno]) # Check if line... |
definition lines. code_lnos = sorted(code_line_numbers(code)) # Do not stop at execution of function definitions. if not module_level and len(code_lnos) > 1: code_lnos = code_lnos[1:] if lineno in code_lnos and lineno not in subcodes_flnos: return 0, (code.co_firstlineno, lineno) # Compute the distance to the next vali... |
line numbers. return subcode_dist actual_lno = code_lnos[idx] dist = actual_lno - lineno if subcode_dist and subcode_dist[0] < dist: return subcode_dist if actual_lno not in subcodes_flnos: return dist, (code.co_firstlineno, actual_lno) else: # The actual line number is the line number of the first # statement of the s... |
raise BdbSourceError('{}: line {} is after the last ' 'valid statement.'.format(self.filename, lineno)) return code_dist[1] |
def get_breakpoints(self, lineno): """Return the list of breakpoints set at lineno.""" try: firstlineno, actual_lno = self.bdb_module.get_actual_bp(lineno) except BdbSourceError: return [] if firstlineno not in self: return [] code_bps = self[firstlineno] if actual_lno not in code_bps: return [] return [bp for bp in so... |
def settrace(self, do_set): """Set or remove the trace function.""" if do_set: sys.settrace(self.trace_dispatch) else: sys.settrace(None) |
def restart(self): """Restart the debugger after source code changes.""" _module_finder.reset() linecache.checkcache() for module_bpts in self.breakpoints.values(): module_bpts.reset() |
def set_until(self, frame, lineno=None): """Stop when the current line number in frame is greater than lineno or when returning from frame.""" if lineno is None: lineno = frame.f_lineno + 1 self._set_stopinfo(frame, lineno) |
def set_trace(self, frame=None): """Start debugging from `frame`. If frame is not specified, debugging starts from caller's frame. """ # First disable tracing temporarily as set_trace() may be called while # tracing is in use. For example when called from a signal handler and # within a debugging session started with r... |
change botframe when the debuggee has been started from an # instance of Pdb with one of the family of run methods. self.reset(ignore_first_call_event=False, botframe=self.botframe) self.topframe = frame while frame: if frame is self.botframe: break botframe = frame frame = frame.f_back else: self.botframe = botframe #... |
self.trace_dispatch self.settrace(True) |
def process_hit_event(self, frame): """Return (stop_state, delete_temporary) at a breakpoint hit event.""" if not self.enabled: return False, False # Count every hit when breakpoint is enabled. self.hits += 1 # A conditional breakpoint. if self.cond: try: if not eval_(self.cond, frame.f_globals, frame.f_locals): return... |
# delete temporary, as another hint to the user. return True, False if self.ignore > 0: self.ignore -= 1 return False, False return True, True |
def listdir(directory): """Returns list of nested files and directories for local directory by path :param directory: absolute or relative path to local directory :return: list nested of file or directory names """ file_names = list() for filename in os.listdir(directory): file_path = os.path.join(directory, filename) ... |
def get_options(option_type, from_options): """Extract options for specified option type from all options :param option_type: the object of specified type of options :param from_options: all options dictionary :return: the dictionary of options for specified type, each option can be filled by value from all options dic... |
dict() for key in option_type.keys: key_with_prefix = f'{option_type.prefix}{key}' if key not in from_options and key_with_prefix not in from_options: _options[key] = '' elif key in from_options: _options[key] = from_options.get(key) else: _options[key] = from_options.get(key_with_prefix) return _options |
def get_headers(self, action, headers_ext=None): """Returns HTTP headers of specified WebDAV actions. :param action: the identifier of action. :param headers_ext: (optional) the addition headers list witch sgould be added to basic HTTP headers for the specified action. :return: the dictionary of headers for specified a... |
headers.extend(headers_ext) if self.webdav.token: webdav_token = f'Authorization: OAuth {self.webdav.token}' headers.append(webdav_token) return dict([map(lambda s: s.strip(), i.split(':')) for i in headers]) |
def execute_request(self, action, path, data=None, headers_ext=None): """Generate request to WebDAV server for specified action and path and execute it. :param action: the action for WebDAV server which should be executed. :param path: the path to resource for action :param data: (optional) Dictionary or list of tuples... |
headers_ext: (optional) the addition headers list witch should be added to basic HTTP headers for the specified action. :return: HTTP response of request. """ response = self.session.request( method=Client.requests[action], url=self.get_url(path), auth=self.webdav.auth, headers=self.get_headers(action, headers_ext), ti... |
def valid(self): """Validates of WebDAV and proxy settings. :return: True in case settings are valid and False otherwise. """ return True if self.webdav.valid() and self.proxy.valid() else False |
def list(self, remote_path=root): """Returns list of nested files and directories for remote WebDAV directory by path. More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_PROPFIND :param remote_path: path to remote directory. :return: list of nested file or directory names. """ directory_u... |
for urn in urns if Urn.compare_path(path, urn.path()) is False] |
def free(self): """Returns an amount of free space on remote WebDAV server. More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_PROPFIND :return: an amount of free space in bytes. """ data = WebDavXmlUtils.create_free_space_request_content() response = self.execute_request(action='free', p... |
def check(self, remote_path=root): """Checks an existence of remote resource on WebDAV server by remote path. More information you can find by link http://webdav.org/specs/rfc4918.html#rfc.section.9.4 :param remote_path: (optional) path to resource on WebDAV server. Defaults is root directory of WebDAV. :return: True i... |
return True return False |
def mkdir(self, remote_path): """Makes new directory on WebDAV server. More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_MKCOL :param remote_path: path to directory :return: True if request executed with code 200 or 201 and False otherwise. """ directory_urn = Urn(remote_path, directory=... |
def download_from(self, buff, remote_path): """Downloads file from WebDAV and writes it in buffer. :param buff: buffer object for writing of downloaded file content. :param remote_path: path to file on WebDAV server. """ urn = Urn(remote_path) if self.is_dir(urn.path()): raise OptionNotValid(name='remote_path', value=r... |
def download(self, remote_path, local_path, progress=None): """Downloads remote resource from WebDAV and save it in local path. More information you can find by link http://webdav.org/specs/rfc4918.html#rfc.section.9.4 :param remote_path: the path to remote resource for downloading can be file and directory. :param loc... |
remote_path=remote_path, progress=progress) |
def download_directory(self, remote_path, local_path, progress=None): """Downloads directory and downloads all nested files and directories from remote WebDAV to local. If there is something on local path it deletes directories and files then creates new. :param remote_path: the path to directory for downloading form W... |
now. """ urn = Urn(remote_path, directory=True) if not self.is_dir(urn.path()): raise OptionNotValid(name='remote_path', value=remote_path) if os.path.exists(local_path): shutil.rmtree(local_path) os.makedirs(local_path) for resource_name in self.list(urn.path()): _remote_path = f'{urn.path()}{resource_name}' _local_pa... |
def open(self, file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None): """Downloads file from WebDAV server and saves it temprorary, then opens it for further manipulations. Has the same interface as built-in open() :param file: the path to remote file for opening. """ urn = ... |
value=file) with tempfile.TemporaryDirectory() as temp_dir: local_path = f'{temp_dir}{os.path.sep}{file}' if remote_file_exists: self.download_file(file, local_path) else: if ('w' in mode or 'a' in mode or 'x' in mode) and os.path.sep in local_path: os.makedirs(local_path.rsplit(os.path.sep, 1)[0], exist_ok=True) with ... |
def download_file(self, remote_path, local_path, progress=None): """Downloads file from WebDAV server and save it locally. More information you can find by link http://webdav.org/specs/rfc4918.html#rfc.section.9.4 :param remote_path: the path to remote file for downloading. :param local_path: the path to save file loca... |
os.makedirs(local_path.rsplit(os.path.sep, 1)[0], exist_ok=True) if not self.check(urn.path()): raise RemoteResourceNotFound(urn.path()) with open(local_path, 'wb') as local_file: response = self.execute_request('download', urn.quote()) for block in response.iter_content(1024): local_file.write(block) |
def download_sync(self, remote_path, local_path, callback=None): """Downloads remote resources from WebDAV server synchronously. :param remote_path: the path to remote resource on WebDAV server. Can be file and directory. :param local_path: the path to save resource locally. :param callback: the callback which will be ... |
def download_async(self, remote_path, local_path, callback=None): """Downloads remote resources from WebDAV server asynchronously :param remote_path: the path to remote resource on WebDAV server. Can be file and directory. :param local_path: the path to save resource locally. :param callback: the callback which will be... |
def upload_to(self, buff, remote_path): """Uploads file from buffer to remote path on WebDAV server. More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_PUT :param buff: the buffer with content for file. :param remote_path: the path to save file remotely on WebDAV server. """ urn = Urn(rem... |
def upload(self, remote_path, local_path, progress=None): """Uploads resource to remote path on WebDAV server. In case resource is directory it will upload all nested files and directories. More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_PUT :param remote_path: the path for uploading r... |
now. """ if os.path.isdir(local_path): self.upload_directory(local_path=local_path, remote_path=remote_path, progress=progress) else: self.upload_file(local_path=local_path, remote_path=remote_path) |
def upload_directory(self, remote_path, local_path, progress=None): """Uploads directory to remote path on WebDAV server. In case directory is exist on remote server it will delete it and then upload directory with nested files and directories. :param remote_path: the path to directory for uploading on WebDAV server. :... |
Urn(remote_path, directory=True) if not urn.is_dir(): raise OptionNotValid(name='remote_path', value=remote_path) if not os.path.isdir(local_path): raise OptionNotValid(name='local_path', value=local_path) if not os.path.exists(local_path): raise LocalResourceNotFound(local_path) if self.check(urn.path()): self.clean(u... |
def upload_file(self, remote_path, local_path, progress=None): """Uploads file to remote path on WebDAV server. File should be 2Gb or less. More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_PUT :param remote_path: the path to uploading file on WebDAV server. :param local_path: the path t... |
raise OptionNotValid(name='remote_path', value=remote_path) if os.path.isdir(local_path): raise OptionNotValid(name='local_path', value=local_path) if not self.check(urn.parent()): raise RemoteParentNotFound(urn.path()) with open(local_path, 'rb') as local_file: file_size = os.path.getsize(local_path) if file_size > se... |
def upload_sync(self, remote_path, local_path, callback=None): """Uploads resource to remote path on WebDAV server synchronously. In case resource is directory it will upload all nested files and directories. :param remote_path: the path for uploading resources on WebDAV server. Can be file and directory. :param local_... |
self.upload(local_path=local_path, remote_path=remote_path) if callback: callback() |
def upload_async(self, remote_path, local_path, callback=None): """Uploads resource to remote path on WebDAV server asynchronously. In case resource is directory it will upload all nested files and directories. :param remote_path: the path for uploading resources on WebDAV server. Can be file and directory. :param loca... |
target = (lambda: self.upload_sync(local_path=local_path, remote_path=remote_path, callback=callback)) threading.Thread(target=target).start() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.