コード例 #1
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 def test_strip_advanced_path_2_locale(self):
     l = "..\\en_EN.UTF-8@calendar=test"
     self.assertEqual(PathTranslator.strip_locale(l),
                      ".." + os.sep + "en_EN")
コード例 #2
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 def test_strip_arbitrary_locale(self):
     l = "de_DE.UTF-8"
     self.assertEqual(PathTranslator.strip_locale(l), "de_DE")
コード例 #3
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 def test_strip_advanced_2_locale(self):
     l = "en_EN@calendar=test"
     self.assertEqual(PathTranslator.strip_locale(l), "en_EN")
コード例 #4
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 def test_strip_empty_locale(self):
     l = ""
     self.assertEqual(PathTranslator.strip_locale(l), "")
コード例 #5
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 def test_strip_empty_locale(self):
     l = ""
     self.assertEqual(PathTranslator.strip_locale(l), "")
コード例 #6
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 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")
コード例 #7
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 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)
コード例 #8
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 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")      
コード例 #9
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 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")   
コード例 #10
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 def test_strip_advanced_path_3_locale(self):
     l = "..\\locale"
     self.assertEqual(PathTranslator.strip_locale(l), ".." + os.sep + "locale")      
コード例 #11
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 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")   
コード例 #12
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 def test_strip_advanced_path_2_locale(self):
     l = "..\\en_EN.UTF-8@calendar=test"
     self.assertEqual(PathTranslator.strip_locale(l), ".." + os.sep + "en_EN")
コード例 #13
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 def test_strip_advanced_2_locale(self):
     l = "en_EN@calendar=test"
     self.assertEqual(PathTranslator.strip_locale(l), "en_EN")
コード例 #14
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 def test_strip_arbitrary_locale(self):
     l = "de_DE.UTF-8"
     self.assertEqual(PathTranslator.strip_locale(l), "de_DE")
コード例 #15
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 def test_strip_advanced_path_3_locale(self):
     l = "..\\locale"
     self.assertEqual(PathTranslator.strip_locale(l),
                      ".." + os.sep + "locale")
コード例 #16
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 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)      
コード例 #17
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 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")
コード例 #18
0
ファイル: TestPathTranslator.py プロジェクト: nixz/covise
 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) 
コード例 #19
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 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")
コード例 #20
0
    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)))
コード例 #21
0
ファイル: TestPathTranslator.py プロジェクト: zyzwhdx/covise
 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)
コード例 #22
0
ファイル: coDocumentMgr.py プロジェクト: nixz/covise
 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)) )