def upload_file(self, local_path, remote_path='A/', skip_checks=False): """ Upload a file to the device. :param local_paths: Path to a local file :type local_paths: str/unicode :param remote_path: Target path on the device :type remote_path: str/unicode :param skip_checks: Skip sanity checks on the device, required if a script is running on the device while uploading. """ # TODO: Test! local_path = os.path.abspath(local_path) remote_path = util.to_camerapath(remote_path) if os.path.isdir(local_path): raise ValueError("`local_path` must be a file, not a directory.") if not skip_checks: if remote_path.endswith("/"): try: status = parse_table( self._lua.call("con:stat", remote_path)) except LuaError: status = {'is_dir': False} if not status['is_dir']: raise ValueError("Remote path '{0}' is not a directory. " "Please leave out the trailing slash if " "you are refering to a file") remote_path = os.path.join(remote_path, os.path.basename(local_path)) self._lua.call("con:upload", local_path, remote_path)
def upload_file(self, local_path, remote_path="A/", skip_checks=False): """ Upload a file to the device. :param local_paths: Path to a local file :type local_paths: str/unicode :param remote_path: Target path on the device :type remote_path: str/unicode :param skip_checks: Skip sanity checks on the device, required if a script is running on the device while uploading. """ # TODO: Test! local_path = os.path.abspath(local_path) remote_path = util.to_camerapath(remote_path) if os.path.isdir(local_path): raise ValueError("`local_path` must be a file, not a directory.") if not skip_checks: if remote_path.endswith("/"): try: status = parse_table(self._lua.call("con:stat", remote_path)) except LuaError: status = {"is_dir": False} if not status["is_dir"]: raise ValueError( "Remote path '{0}' is not a directory. " "Please leave out the trailing slash if " "you are refering to a file" ) remote_path = os.path.join(remote_path, os.path.basename(local_path)) self._lua.call("con:upload", local_path, remote_path)
def _parse_message(self, raw_msg): value = raw_msg.value if raw_msg.subtype == 'table': value = parse_table(self._lua.eval(raw_msg.value)) return Message(type=raw_msg.type, script_id=raw_msg.script_id, value=value)
def _parse_message(self, raw_msg): value = raw_msg.value if raw_msg.subtype == "table": value = parse_table(self._lua.eval(raw_msg.value)) return Message(type=raw_msg.type, script_id=raw_msg.script_id, value=value)