def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a # 250 character directory in the cwd (except - cwd may be on a drive # not supporting \\\\?\\ (eg, network share) - so use temp. import win32file basename = "a" * 250 # but we need to ensure we use the 'long' version of the # temp dir for later comparison. long_temp_dir = win32api.GetLongPathNameW(tempfile.gettempdir()) fname = "\\\\?\\" + os.path.join(long_temp_dir, basename) try: win32file.CreateDirectoryW(fname, None) except win32api.error as details: if details.winerror != winerror.ERROR_ALREADY_EXISTS: raise try: # GetFileAttributes automatically calls GetFileAttributesW when # passed unicode try: attr = win32api.GetFileAttributes(fname) except win32api.error as details: if details.winerror != winerror.ERROR_FILENAME_EXCED_RANGE: raise attr = win32api.GetFileAttributes(str(fname)) assert attr & win32con.FILE_ATTRIBUTE_DIRECTORY, attr long_name = win32api.GetLongPathNameW(fname) assert long_name.lower() == fname.lower() finally: win32file.RemoveDirectory(fname)
def testShortUnicodeNames(self): try: me = __file__ except NameError: me = sys.argv[0] fname = os.path.abspath(me).lower() # passing unicode should cause GetShortPathNameW to be called. short_name = win32api.GetShortPathName(str(fname)).lower() self.failUnless(isinstance(short_name, str)) long_name = win32api.GetLongPathName(short_name).lower() self.failUnless( long_name == fname, "Expected long name ('%s') to be original name ('%s')" % (long_name, fname), ) self.failUnlessEqual(long_name, win32api.GetLongPathNameW(short_name).lower()) long_name = win32api.GetLongPathNameW(short_name).lower() self.failUnless( type(long_name) == str, "GetLongPathNameW returned type '%s'" % (type(long_name), ), ) self.failUnless( long_name == fname, "Expected long name ('%s') to be original name ('%s')" % (long_name, fname), )
def testShortLongPathNames(self): try: me = __file__ except NameError: me = sys.argv[0] fname = os.path.abspath(me).lower() short_name = win32api.GetShortPathName(fname).lower() long_name = win32api.GetLongPathName(short_name).lower() self.failUnless( long_name == fname, "Expected long name ('%s') to be original name ('%s')" % (long_name, fname), ) self.failUnlessEqual(long_name, win32api.GetLongPathNameW(short_name).lower()) long_name = win32api.GetLongPathNameW(short_name).lower() self.failUnless( type(long_name) == str, "GetLongPathNameW returned type '%s'" % (type(long_name), ), ) self.failUnless( long_name == fname, "Expected long name ('%s') to be original name ('%s')" % (long_name, fname), )
def check_shortpathname(fn): lfn = win32api.GetLongPathNameW(fn) fn = os.path.normcase(fn) lfn = os.path.normcase(lfn) if lfn != fn: print("ShortPathName: Expected %s, got %s" % (fn, lfn)) raise SystemExit(-1)
def move_ensure_casing(source_path, target_path): """Moves a file from source_path to target_path. If the move would result just in the name changing the case apply workarounds for Linux and Windows to ensure the case change is applied on case-insensitive file systems. Otherwise use shutil.move to move the file. """ source_path = os.path.normpath(source_path) target_path = os.path.normpath(target_path) if source_path == target_path: return # Special handling is only required if both paths refer to the same file # but the file name differs in casing. # Also macOS does allow renaming only the casing and does not need special # handling. if not IS_MACOS and samefile_different_casing(source_path, target_path): if IS_LINUX: # On Linux always force a double move _move_force_rename(source_path, target_path) return elif IS_WIN and win32api: # Windows supports case renaming for NTFS and SMB shares, but not # on FAT32 or exFAT file systems. Perform a normal move first, # then check the result. shutil.move(source_path, target_path) try: # Get the path in the actual casing as stored on disk actual_path = win32api.GetLongPathNameW( win32api.GetShortPathName(target_path)) if samefile_different_casing(target_path, actual_path): _move_force_rename(source_path, target_path) except pywintypes.error: pass return # Just perform a normal move shutil.move(source_path, target_path)
def setUp(self): with tempfile.NamedTemporaryFile(delete=False) as tf: tf.write(b'external') self.temp_file = os.path.abspath(tf.name) if iswindows: import win32api self.temp_file = win32api.GetLongPathNameW(self.temp_file)
def test_getsize_helper(fname): filename = os.path.join(dirname, fname) write_file(filename, "abcdefghij" * 12345) if 'nt' == os.name: self.assertEqual(getsize(filename), 10 * 12345) # Expand the directory names, which are in the short format, # to test the case where the full path (including the directory) # is longer than 255 characters. import win32api lname = win32api.GetLongPathNameW(extended_path(filename)) self.assertEqual(getsize(lname), 10 * 12345) # this function returns a byte string instead of Unicode counter = 0 for child in children_in_directory(dirname, False): self.assertEqual(getsize(child), 10 * 12345) counter += 1 self.assertEqual(counter, 1) if 'posix' == os.name: output = subprocess.Popen( ["du", "-h", filename], stdout=subprocess.PIPE).communicate()[0] output = output.replace("\n", "") du_size = output.split("\t")[0] + "B" print "output = '%s', size='%s'" % (output, du_size) du_bytes = human_to_bytes(du_size, 'du') print output, du_size, du_bytes self.assertEqual(getsize(filename), du_bytes) delete(filename) self.assert_(not os.path.exists(filename))
def testShortLongPathNames(self): try: me = __file__ except NameError: me = sys.argv[0] fname = os.path.abspath(me).lower() short_name = win32api.GetShortPathName(fname).lower() long_name = win32api.GetLongPathName(short_name).lower() assert long_name == fname, "Expected long name ('%s') to be original name ('%s')" % \ (long_name, fname) assert long_name == \ win32api.GetLongPathNameW(short_name).lower() long_name = win32api.GetLongPathNameW(short_name).lower() assert isinstance( long_name, str), "GetLongPathNameW returned type '%s'" % \ (type(long_name),) assert long_name == fname, "Expected long name ('%s') to be original name ('%s')" % \ (long_name, fname)
def normalize_event_filename(filename, action=True): # type: (unicode, bool) -> unicode """ Normalize a file name. :param unicode filename: The file name to normalize. :param bool action: Apply changes on the file system. :return unicode: The normalized file name. """ # NXDRIVE-688: Ensure the name is stripped for a file stripped = filename.strip() if sys.platform == 'win32': # Windows does not allow files/folders ending with space(s) filename = stripped elif (action and filename != stripped and os.path.exists(filename) and not os.path.isdir(filename)): # We can have folders ending with spaces log.debug('Forcing space normalization: %r -> %r', filename, stripped) os.rename(filename, stripped) filename = stripped # NXDRIVE-188: Normalize name on the file system, if needed try: normalized = unicodedata.normalize('NFC', unicode(filename, 'utf-8')) except TypeError: normalized = unicodedata.normalize('NFC', unicode(filename)) if sys.platform == 'darwin': return normalized elif sys.platform == 'win32' and os.path.exists(filename): """ If `filename` exists, and as Windows is case insensitive, the result of Get(Full|Long|Short)PathName() could be unexpected because it will return the path of the existant `filename`. Check this simplified code session (the file "ABC.txt" exists): >>> win32api.GetLongPathName('abc.txt') 'ABC.txt' >>> win32api.GetLongPathName('ABC.TXT') 'ABC.txt' >>> win32api.GetLongPathName('ABC.txt') 'ABC.txt' So, to counter that behavior, we save the actual file name and restore it in the full path. """ long_path = win32api.GetLongPathNameW(filename) filename = os.path.join(os.path.dirname(long_path), os.path.basename(filename)) if action and filename != normalized and os.path.exists(filename): log.debug('Forcing normalization: %r -> %r', filename, normalized) os.rename(filename, normalized) return normalized
def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a # 250 character directory in the cwd (except - cwd may be on a drive # not supporting \\\\?\\ (eg, network share) - so use temp. import win32file basename = "a" * 250 # but we need to ensure we use the 'long' version of the # temp dir for later comparison. long_temp_dir = win32api.GetLongPathNameW(tempfile.gettempdir()) fname = "\\\\?\\" + os.path.join(long_temp_dir, basename) try: win32file.CreateDirectoryW(fname, None) except win32api.error, details: if details.winerror!=winerror.ERROR_ALREADY_EXISTS: raise
def GetAbsPath(path): """Get the absolute path of a file of a file. @param path: string @return: string @note: on windows if win32api is available short notation paths will be converted to the proper long name. """ rpath = os.path.abspath(path) # Resolve short path notation on Windows when possible if WIN and win32api is not None and u"~" in rpath: try: rpath = win32api.GetLongPathNameW(rpath) except Exception: # Ignore errors from win32api calls pass return rpath
class FileNames(unittest.TestCase): def testShortLongPathNames(self): try: me = __file__ except NameError: me = sys.argv[0] fname = os.path.abspath(me) short_name = win32api.GetShortPathName(fname) long_name = win32api.GetLongPathName(short_name) self.failUnless(long_name==fname, \ "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) self.failUnlessEqual(long_name, win32api.GetLongPathNameW(short_name)) long_name = win32api.GetLongPathNameW(short_name) self.failUnless( type(long_name) == unicode, "GetLongPathNameW returned type '%s'" % (type(long_name), )) self.failUnless(long_name==fname, \ "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) def testShortUnicodeNames(self): try: me = __file__ except NameError: me = sys.argv[0] fname = os.path.abspath(me) # passing unicode should cause GetShortPathNameW to be called. short_name = win32api.GetShortPathName(unicode(fname)) self.failUnless(isinstance(short_name, unicode)) long_name = win32api.GetLongPathName(short_name) self.failUnless(long_name==fname, \ "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) self.failUnlessEqual(long_name, win32api.GetLongPathNameW(short_name)) long_name = win32api.GetLongPathNameW(short_name) self.failUnless( type(long_name) == unicode, "GetLongPathNameW returned type '%s'" % (type(long_name), )) self.failUnless(long_name==fname, \ "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a # 250 character directory in the cwd. import win32file basename = "a" * 250 fname = "\\\\?\\" + os.path.join(os.getcwd(), basename) try: win32file.CreateDirectoryW(fname, None) except win32api.error, details: if details[0] != winerror.ERROR_ALREADY_EXISTS: raise try: # GetFileAttributes automatically calls GetFileAttributesW when # passed unicode try: attr = win32api.GetFileAttributes(fname) except win32api.error, details: if details[0] != winerror.ERROR_FILENAME_EXCED_RANGE: raise attr = win32api.GetFileAttributes(unicode(fname)) self.failUnless(attr & win32con.FILE_ATTRIBUTE_DIRECTORY, attr) long_name = win32api.GetLongPathNameW(fname) self.failUnlessEqual(long_name, fname)
class FileNames(unittest.TestCase): def testShortLongPathNames(self): try: me = __file__ except NameError: me = sys.argv[0] fname = os.path.abspath(me).lower() short_name = win32api.GetShortPathName(fname).lower() long_name = win32api.GetLongPathName(short_name).lower() self.failUnless(long_name==fname, \ "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) self.failUnlessEqual(long_name, win32api.GetLongPathNameW(short_name).lower()) long_name = win32api.GetLongPathNameW(short_name).lower() self.failUnless(type(long_name)==unicode, "GetLongPathNameW returned type '%s'" % (type(long_name),)) self.failUnless(long_name==fname, \ "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) def testShortUnicodeNames(self): try: me = __file__ except NameError: me = sys.argv[0] fname = os.path.abspath(me).lower() # passing unicode should cause GetShortPathNameW to be called. short_name = win32api.GetShortPathName(unicode(fname)).lower() self.failUnless(isinstance(short_name, unicode)) long_name = win32api.GetLongPathName(short_name).lower() self.failUnless(long_name==fname, \ "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) self.failUnlessEqual(long_name, win32api.GetLongPathNameW(short_name).lower()) long_name = win32api.GetLongPathNameW(short_name).lower() self.failUnless(type(long_name)==unicode, "GetLongPathNameW returned type '%s'" % (type(long_name),)) self.failUnless(long_name==fname, \ "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a # 250 character directory in the cwd (except - cwd may be on a drive # not supporting \\\\?\\ (eg, network share) - so use temp. import win32file basename = "a" * 250 # but we need to ensure we use the 'long' version of the # temp dir for later comparison. long_temp_dir = win32api.GetLongPathNameW(tempfile.gettempdir()) fname = "\\\\?\\" + os.path.join(long_temp_dir, basename) try: win32file.CreateDirectoryW(fname, None) except win32api.error, details: if details.winerror!=winerror.ERROR_ALREADY_EXISTS: raise try: # GetFileAttributes automatically calls GetFileAttributesW when # passed unicode try: attr = win32api.GetFileAttributes(fname) except win32api.error, details: if details.winerror != winerror.ERROR_FILENAME_EXCED_RANGE: raise attr = win32api.GetFileAttributes(unicode(fname)) self.failUnless(attr & win32con.FILE_ATTRIBUTE_DIRECTORY, attr) long_name = win32api.GetLongPathNameW(fname) self.failUnlessEqual(long_name.lower(), fname.lower())
def main(): args = parse_args() subtitle_file = os.path.abspath( win32api.GetLongPathNameW(args.subtitle_file)) ts_path = os.path.splitext(subtitle_file)[0] + ".txt" sub_file = sublib.SubtitleFile.load(subtitle_file) language = sub_file.guess_language() old_transcript = sub_file.transcript ## with open(ts_path, "w", encoding="utf-8-sig", newline="\r\n") as f: f.write(old_transcript) try: if args.grammar_checker: grammar_checker = args.grammar_checker name = get_name(grammar_checker) if not os.path.isfile(grammar_checker): raise FileNotFoundError( "can't find {!r}".format(grammar_checker)) else: name, grammar_checker = get_grammar_checker(language) except FileNotFoundError as e: print("{} ({}): {}".format(os.path.basename(sub_file.file), language, e)) return 127 msg = None assert os.path.isfile(ts_path) and os.path.getsize(ts_path) try: if name.lower() == "antidote": has_background_proc = has_background_antidote() with subprocess.Popen([grammar_checker, ts_path]) as proc: poll_window(ts_path, name) if not has_background_proc: proc.terminate() else: subprocess.call([grammar_checker, ts_path]) with open(ts_path, "rb") as f: buf = f.read() encoding = detect_encoding(buf) transcript = re.sub(r"\r\n|\r", "\n", buf.decode(encoding)) try: if encoding.startswith("utf"): changes = sub_file.update_transcript(transcript) else: changes = update_transcript_non_unicode(sub_file, transcript) except ValueError as e: msg = e.args[0] return 2 msg = "{} updated cue{}".format(changes, "s" if changes != 1 else "") if changes: try: sub_file.save() except UnicodeEncodeError: old_encoding = sub_file.encoding sub_file.save(encoding="utf-8-sig") print("File converted from {} to utf-8".format(old_encoding)) return 0 else: return 1 finally: os.remove(ts_path) print("{} ({}): {}".format(os.path.basename(sub_file.file), language, msg))
def check_shortpathname(fn): lfn = win32api.GetLongPathNameW(fn) fn = os.path.normcase(fn) lfn = os.path.normcase(lfn) if lfn != fn: print("ShortPathName: Expected %s, got %s" % (fn, lfn)) raise SystemExit(-1) print("sys.executable:", ascii(sys.executable)) if not os.path.exists(sys.executable): raise SystemExit("sys.executable does not exist.") check_shortpathname(sys.executable) print("sys.argv[0]:", ascii(sys.argv[0])) if not os.path.exists(sys.argv[0]): raise SystemExit("sys.argv[0] does not exist.") check_shortpathname(sys.argv[0]) print("sys._MEIPASS:"******"sys._MEIPASS does not exist.") tmp = os.path.normcase(win32api.GetTempPath()) if os.path.normcase(win32api.GetLongPathNameW(tmp)) == tmp: # Test only if TempPath is not a short path. This might happen if e.g # TMP=c:\users\runner~1\appdata\local\temp, since the username is too long check_shortpathname(sys._MEIPASS)
def real_path(path): """Get the real capitalisation of a path on Windows.""" if not os.path.exists(path): return path return win32api.GetLongPathNameW(win32api.GetShortPathName(path))
def setUpApp(self, server_profile=None, register_roots=True): if Manager._singleton: Manager._singleton = None # Save the current path for test files self.location = dirname(__file__) # Install callback early to be called the last self.addCleanup(self._check_cleanup) # Check the Nuxeo server test environment self.nuxeo_url = os.environ.get('NXDRIVE_TEST_NUXEO_URL', 'http://localhost:8080/nuxeo') self.admin_user = os.environ.get('NXDRIVE_TEST_USER', 'Administrator') self.password = os.environ.get('NXDRIVE_TEST_PASSWORD', 'Administrator') self.report_path = os.environ.get('REPORT_PATH') self.tearedDown = False self.tmpdir = os.path.join(os.environ.get('WORKSPACE', ''), 'tmp') self.addCleanup(clean_dir, self.tmpdir) if not os.path.isdir(self.tmpdir): os.makedirs(self.tmpdir) self.upload_tmp_dir = tempfile.mkdtemp(u'-nxdrive-uploads', dir=self.tmpdir) # Check the local filesystem test environment self.local_test_folder_1 = tempfile.mkdtemp(u'drive-1', dir=self.tmpdir) self.local_test_folder_2 = tempfile.mkdtemp(u'drive-2', dir=self.tmpdir) # Correct the casing of the temp folders for windows if sys.platform == 'win32': import win32api self.local_test_folder_1 = win32api.GetLongPathNameW( self.local_test_folder_1) self.local_test_folder_2 = win32api.GetLongPathNameW( self.local_test_folder_2) self.local_nxdrive_folder_1 = os.path.join(self.local_test_folder_1, u'Nuxeo Drive') os.mkdir(self.local_nxdrive_folder_1) self.local_nxdrive_folder_2 = os.path.join(self.local_test_folder_2, u'Nuxeo Drive') os.mkdir(self.local_nxdrive_folder_2) self.nxdrive_conf_folder_1 = os.path.join(self.local_test_folder_1, u'nuxeo-drive-conf') os.mkdir(self.nxdrive_conf_folder_1) self.nxdrive_conf_folder_2 = os.path.join(self.local_test_folder_2, u'nuxeo-drive-conf') os.mkdir(self.nxdrive_conf_folder_2) Options.delay = TEST_DEFAULT_DELAY # Options.autolock_interval = 30 Options.nxdrive_home = self.nxdrive_conf_folder_1 self.manager_1 = Manager() self.connected = False i18n_path = self.location + '/resources/i18n.js' Translator(self.manager_1, i18n_path) Options.nxdrive_home = self.nxdrive_conf_folder_2 Manager._singleton = None self.manager_2 = Manager() self.version = __version__ url = self.nuxeo_url log.debug("Will use %s as url", url) if '#' in url: # Remove the engine type for the rest of the test self.nuxeo_url = url.split('#')[0] self.setUpServer(server_profile) self.addCleanup(self.tearDownServer, server_profile) self.addCleanup(self._stop_managers) self._wait_sync = {} self._wait_remote_scan = {} self._remote_changes_count = {} self._no_remote_changes = {} # Set engine_1 and engine_2 attributes self.bind_engine(1, start_engine=False) self.queue_manager_1 = self.engine_1.get_queue_manager() self.bind_engine(2, start_engine=False) self.queue_manager_2 = self.engine_2.get_queue_manager() self.sync_root_folder_1 = os.path.join(self.local_nxdrive_folder_1, self.workspace_title_1) self.sync_root_folder_2 = os.path.join(self.local_nxdrive_folder_2, self.workspace_title_2) self.local_root_client_1 = self.engine_1.get_local_client() self.local_root_client_2 = self.engine_2.get_local_client() self.local_client_1 = self.get_local_client(self.sync_root_folder_1) self.local_client_2 = self.get_local_client(self.sync_root_folder_2) # Document client to be used to create remote test documents # and folders self.remote_document_client_1 = RemoteDocumentClientForTests( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, base_folder=self.workspace_1, upload_tmp_dir=self.upload_tmp_dir) self.remote_document_client_2 = RemoteDocumentClientForTests( self.nuxeo_url, self.user_2, u'nxdrive-test-device-2', self.version, password=self.password_2, base_folder=self.workspace_2, upload_tmp_dir=self.upload_tmp_dir) # File system client to be used to create remote test documents # and folders self.remote_file_system_client_1 = RemoteFileSystemClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, upload_tmp_dir=self.upload_tmp_dir) self.remote_file_system_client_2 = RemoteFileSystemClient( self.nuxeo_url, self.user_2, u'nxdrive-test-device-2', self.version, password=self.password_2, upload_tmp_dir=self.upload_tmp_dir) self.remote_restapi_client_admin = RestAPIClient( self.nuxeo_url, self.admin_user, u'nxdrive-test-device-2', self.version, password=self.password) # Register sync roots if register_roots: self.remote_document_client_1.register_as_root(self.workspace_1) self.addCleanup(self._unregister, self.workspace_1) self.remote_document_client_2.register_as_root(self.workspace_2) self.addCleanup(self._unregister, self.workspace_2)
def setUpApp(self, server_profile=None, register_roots=True): if Manager._singleton: Manager._singleton = None # Install callback early to be called the last self.addCleanup(self._check_cleanup) self.report_path = os.environ.get("REPORT_PATH") self.tmpdir = os.path.join(os.environ.get("WORKSPACE", ""), "tmp") self.addCleanup(clean_dir, self.tmpdir) if not os.path.isdir(self.tmpdir): os.makedirs(self.tmpdir) self.upload_tmp_dir = tempfile.mkdtemp("-nxdrive-uploads", dir=self.tmpdir) # Check the local filesystem test environment self.local_test_folder_1 = tempfile.mkdtemp("drive-1", dir=self.tmpdir) self.local_test_folder_2 = tempfile.mkdtemp("drive-2", dir=self.tmpdir) # Correct the casing of the temp folders for windows if WINDOWS: import win32api self.local_test_folder_1 = win32api.GetLongPathNameW( self.local_test_folder_1) self.local_test_folder_2 = win32api.GetLongPathNameW( self.local_test_folder_2) self.local_nxdrive_folder_1 = os.path.join(self.local_test_folder_1, "Nuxeo Drive") os.mkdir(self.local_nxdrive_folder_1) self.local_nxdrive_folder_2 = os.path.join(self.local_test_folder_2, "Nuxeo Drive") os.mkdir(self.local_nxdrive_folder_2) self.nxdrive_conf_folder_1 = os.path.join(self.local_test_folder_1, "nuxeo-drive-conf") os.mkdir(self.nxdrive_conf_folder_1) self.nxdrive_conf_folder_2 = os.path.join(self.local_test_folder_2, "nuxeo-drive-conf") os.mkdir(self.nxdrive_conf_folder_2) Options.delay = TEST_DEFAULT_DELAY Options.nxdrive_home = self.nxdrive_conf_folder_1 self.manager_1 = Manager() self.connected = False i18n_path = self.location + "/resources/i18n" Translator(self.manager_1, i18n_path) Options.nxdrive_home = self.nxdrive_conf_folder_2 Manager._singleton = None self.manager_2 = Manager() self.setUpServer(server_profile) self.addCleanup(self.tearDownServer, server_profile) self.addCleanup(self._stop_managers) self.addCleanup(self.generate_report) self._wait_sync = {} self._wait_remote_scan = {} self._remote_changes_count = {} self._no_remote_changes = {} # Set engine_1 and engine_2 attributes self.bind_engine(1, start_engine=False) self.queue_manager_1 = self.engine_1.get_queue_manager() self.bind_engine(2, start_engine=False) self.sync_root_folder_1 = os.path.join(self.local_nxdrive_folder_1, self.workspace_title_1) self.sync_root_folder_2 = os.path.join(self.local_nxdrive_folder_2, self.workspace_title_2) self.local_root_client_1 = self.engine_1.local self.local_1 = self.get_local_client(self.sync_root_folder_1) self.local_2 = self.get_local_client(self.sync_root_folder_2) # Document client to be used to create remote test documents # and folders self.remote_document_client_1 = DocRemote( pytest.nuxeo_url, self.user_1, "nxdrive-test-device-1", pytest.version, password=self.password_1, base_folder=self.workspace_1, upload_tmp_dir=self.upload_tmp_dir, ) self.remote_document_client_2 = DocRemote( pytest.nuxeo_url, self.user_2, "nxdrive-test-device-2", pytest.version, password=self.password_2, base_folder=self.workspace_2, upload_tmp_dir=self.upload_tmp_dir, ) # File system client to be used to create remote test documents # and folders self.remote_1 = RemoteBase( pytest.nuxeo_url, self.user_1, "nxdrive-test-device-1", pytest.version, password=self.password_1, base_folder=self.workspace_1, upload_tmp_dir=self.upload_tmp_dir, ) self.remote_2 = RemoteBase( pytest.nuxeo_url, self.user_2, "nxdrive-test-device-2", pytest.version, password=self.password_2, base_folder=self.workspace_2, upload_tmp_dir=self.upload_tmp_dir, ) # Register sync roots if register_roots: self.remote_1.register_as_root(self.workspace_1) self.addCleanup(self._unregister, self.workspace_1) self.remote_2.register_as_root(self.workspace_2) self.addCleanup(self._unregister, self.workspace_2)