def test_butufy_path_when_existing(self): l = "fr_FR.UTF-8" p = "./" + self.testdir + "\\" + self.filename self.assertEqual( PathTranslator.translate_path(l, p), "." + os.sep + self.testdir + os.sep + "fr_FR" + os.sep + self.filename)
def test_dont_translate_path_when_not_existing(self): l = "fr_FR.UTF-8" p = "./" + self.testdir + "/non_existing_file.txt" self.assertEqual(PathTranslator.translate_path(l, p), "./" + self.testdir + "/non_existing_file.txt")
def test_dont_alter_path_when_not_existing(self): l = "nz_NZ.UTF-8" p = "./" + self.testdir + "\\" + self.filename self.assertEqual(PathTranslator.translate_path(l, p), "./" + self.testdir + "\\" + self.filename)
def test_translate_path_with_empty_locale(self): l = "" p = "./" + self.testdir1 + "/non_existing_file.txt" self.assertEqual( PathTranslator.translate_path(l, p), "." + os.sep + "test_dir" + os.sep + "non_existing_file.txt")
def test_translate_path_with_locale(self): l = "fr_FR.UTF-8" p = "./" + self.testdir + "/" + self.filename self.assertEqual( PathTranslator.translate_path(l, p), "." + os.sep + "test_dir" + os.sep + "fr_FR" + os.sep + "file.dat")
def test_butufy_path_when_existing(self): l = "fr_FR.UTF-8" p = "./" + self.testdir + "\\" + self.filename self.assertEqual(PathTranslator.translate_path(l,p), "." + os.sep + self.testdir + os.sep + "fr_FR" + os.sep + self.filename)
def sendImagePathToWebserver(self): if covise.coConfigIsOn("vr-prepare.RemoteDeviceControll", False) and self.params.imageName != None: import os import vtrans import PathTranslator # starting point of # image path processing imageName = self.params.imageName sNum = '1' # compute the image corresponding to step number imageName = imageName.replace('\\', '/') ## just to be shure imageName = imageName.replace(os.sep, '/') pos = imageName.rfind('/') if pos >= 0: dirName = imageName[:pos] baseName = imageName[pos + 1:] imageNumber = int(self.params.pageNo) imageSuffix = '' nPos = baseName.rfind('.') if nPos >= 0: sNum = baseName[:nPos] imageSuffix = baseName[nPos + 1:] iNum = int(sNum) # for backward compatibility # in cc versions lesser than 3.2 # images were alloed to start with zero (0.png) if iNum == 0: imageNumber = int(self.params.pageNo) - 1 #compose all back togerther imageName = dirName + '/' + str( imageNumber) + '.' + imageSuffix # get the language environment settings coPath = vtrans.covisePath localePrefix = covise.getCoConfigEntry( "COVER.Localization.LocalePrefix") languageLocale = vtrans.languageLocale loc = localePrefix + "/" + languageLocale fullPathToImage = coPath + "/" + imageName # retrieve localized path fullPathToImage = PathTranslator.translate_path( loc, fullPathToImage) # retrieve relative path again imageName = fullPathToImage[len(coPath) + 1:] path_to_current_image = imageName # again... # this time for the browser # compute the image corresponding to step number path_to_current_image = path_to_current_image.replace('\\', '/') ## just to be shure path_to_current_image = path_to_current_image.replace(os.sep, '/') # pack the message msg = 'VRT IMAGE ' + path_to_current_image + '.' + str( self.params.maxPage) + '.' + sNum # send it away destinationHost = covise.getCoConfigEntry( "vr-prepare.RemoteDeviceHost") if not destinationHost: destinationHost = "127.0.0.1" destinationPort = covise.getCoConfigEntry( "vr-prepare.RemoteDevicePort") if not destinationPort: destinationPort = "44142" sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.sendto(str(msg), (destinationHost, int(destinationPort)))
def test_dont_alter_path_when_not_existing(self): l = "nz_NZ.UTF-8" p = "./" + self.testdir + "\\" + self.filename self.assertEqual(PathTranslator.translate_path(l,p), "./" + self.testdir + "\\" + self.filename)
def test_dont_translate_path_when_not_existing(self): l = "fr_FR.UTF-8" p = "./" + self.testdir + "/non_existing_file.txt" self.assertEqual(PathTranslator.translate_path(l,p), "./" + self.testdir + "/non_existing_file.txt")
def test_translate_path_with_locale(self): l = "fr_FR.UTF-8" p = "./" + self.testdir + "/" + self.filename self.assertEqual(PathTranslator.translate_path(l,p), "." + os.sep + "test_dir" + os.sep + "fr_FR" + os.sep + "file.dat")
def test_translate_path_with_empty_locale(self): l = "" p = "./" + self.testdir1 + "/non_existing_file.txt" self.assertEqual(PathTranslator.translate_path(l,p), "." + os.sep + "test_dir" + os.sep + "non_existing_file.txt")
def sendImagePathToWebserver(self): if covise.coConfigIsOn("vr-prepare.RemoteDeviceControll", False) and self.params.imageName != None: import os import vtrans import PathTranslator # starting point of # image path processing imageName = self.params.imageName sNum = '1' # compute the image corresponding to step number imageName = imageName.replace('\\', '/') ## just to be shure imageName = imageName.replace(os.sep, '/') pos = imageName.rfind('/') if pos >= 0: dirName = imageName[:pos] baseName = imageName[pos+1:] imageNumber = int(self.params.pageNo) imageSuffix = '' nPos = baseName.rfind('.') if nPos >= 0: sNum = baseName[:nPos] imageSuffix = baseName[nPos+1:] iNum = int(sNum) # for backward compatibility # in cc versions lesser than 3.2 # images were alloed to start with zero (0.png) if iNum == 0: imageNumber = int(self.params.pageNo) - 1 #compose all back togerther imageName = dirName + '/' + str(imageNumber) + '.' + imageSuffix # get the language environment settings coPath = vtrans.covisePath localePrefix = covise.getCoConfigEntry("COVER.Localization.LocalePrefix") languageLocale = vtrans.languageLocale loc = localePrefix + "/" + languageLocale fullPathToImage = coPath + "/" +imageName # retrieve localized path fullPathToImage = PathTranslator.translate_path(loc, fullPathToImage) # retrieve relative path again imageName = fullPathToImage[len(coPath)+1:] path_to_current_image = imageName # again... # this time for the browser # compute the image corresponding to step number path_to_current_image = path_to_current_image.replace('\\', '/') ## just to be shure path_to_current_image = path_to_current_image.replace(os.sep, '/') # pack the message msg = 'VRT IMAGE ' + path_to_current_image + '.' + str(self.params.maxPage)+ '.' + sNum # send it away destinationHost = covise.getCoConfigEntry("vr-prepare.RemoteDeviceHost") if not destinationHost: destinationHost = "127.0.0.1" destinationPort = covise.getCoConfigEntry("vr-prepare.RemoteDevicePort") if not destinationPort: destinationPort = "44142" sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.sendto( str(msg),(destinationHost,int(destinationPort)) )