def downloadPackage(self ):    
     if( not system.isOnNao() ):
         print( "ERR: LifeData.downloadPackage: must be executed on a real Nao!" );
         return false;        
     filetools.makedirsQuiet( self.strDownloadedPath );
     ut = naoqitools.myGetProxy( "UsageTools" );
     # ut.setDebugMode( True );
     nettools.getHtmlPage( self.getRemotePath() + "metadata.xml", bWaitAnswer = True, rTimeOutForAnswerInSec = 0, strSaveAs = self.strDownloadedPath + "metadata.xml" );            
     nettools.getHtmlPage( self.getRemotePath() + "life_data.zip", bWaitAnswer = True, rTimeOutForAnswerInSec = 0, strSaveAs = self.strDownloadedPath + "life_data.zip", bTryToUseCpp = False ); # notre bibliotheque cpp ne gere pas les si gros fichiers, pfff...    
Exemple #2
0
 def downloadPackage(self):
     if (not system.isOnNao()):
         print(
             "ERR: LifeData.downloadPackage: must be executed on a real Nao!"
         )
         return false
     filetools.makedirsQuiet(self.strDownloadedPath)
     ut = naoqitools.myGetProxy("UsageTools")
     # ut.setDebugMode( True );
     nettools.getHtmlPage(self.getRemotePath() + "metadata.xml",
                          bWaitAnswer=True,
                          rTimeOutForAnswerInSec=0,
                          strSaveAs=self.strDownloadedPath + "metadata.xml")
     nettools.getHtmlPage(self.getRemotePath() + "life_data.zip",
                          bWaitAnswer=True,
                          rTimeOutForAnswerInSec=0,
                          strSaveAs=self.strDownloadedPath +
                          "life_data.zip",
                          bTryToUseCpp=False)
Exemple #3
0
    def generatePackage(self,
                        strNaoqiVersion,
                        bRegenerateTempFolder=True,
                        bRegenerateZip=True,
                        bForBehavior=False):
        "generate the big archive containing all the life data"
        "return true if ok"
        "bForBehavior: to be used as ressources of a choregraphe project"
        print("INF: LifeData.generatePackage( strNaoqiVersion = '%s' )" %
              strNaoqiVersion)
        if (system.isOnNao()):
            print(
                "ERR: LifeData.generatePackage: must be executed on a computer within the git folder!"
            )
            return false
        if (not bForBehavior):
            strTempPath = self.path + 'temp_life_data/'
        else:
            strTempPath = self.path + 'temp_life_data_light/'
        if (bRegenerateTempFolder):
            filetools.removeDirsQuiet(strTempPath)
            filetools.makedirsQuiet(strTempPath)

            # python script
            strObjPath = strTempPath + "python/"
            filetools.makedirsQuiet(strObjPath)
            filetools.copyDirectory(self.gitPath + "appu_shared/sdk/abcdk/",
                                    strObjPath + 'abcdk/', '.pyc')
            filetools.copyFile(self.gitPath + "appu_work/altools.py",
                               strObjPath + 'altools.py')
            filetools.copyFile(self.gitPath + "appu_work/naoconfig.py.sample",
                               strObjPath + 'naoconfig.py')
            filetools.copyFile(self.gitPath + "appu_work/naolibrary.py",
                               strObjPath + 'naolibrary.py')
            filetools.copyFile(self.gitPath + "appu_work/behaviordata.py",
                               strObjPath + 'behaviordata.py')
            filetools.copyFile(
                self.gitPath + "appu_work/autonomous_pose_default.py",
                strObjPath + 'autonomous_pose_default.py')
            filetools.copyFile(self.path + "life_data.py",
                               strObjPath + 'life_data.py')
            # update version:
            if (bForBehavior):
                strFilename = strObjPath + 'life_data.py'
                rVersion = self.getFileVersion(strFilename)
                rVersionLight = rVersion - 0.001
                strSkul = "rLifeDataVersionNumber = %g;"
                filetools.replaceInFile(strSkul % rVersion,
                                        strSkul % rVersionLight, strFilename)

            # main behaviors (exported to xar)
            strExportScript = self.gitPath + "appu_shared/scripts/python/convert_crg_into_new_xars.py"
            print("INF: LifeData.generatePackage: launching script '%s'" %
                  strExportScript)

            os.system("python " + strExportScript + " " + ".." + " " +
                      "autonomous2")
            strObjPath = strTempPath + "main_behaviors/autonomous2/"
            filetools.copyDirectory(self.path + "./exported/autonomous2/",
                                    strObjPath)

            os.system("python " + strExportScript + " " + self.gitPath +
                      "appu_applications/beta_menu" + " " + "beta_menu2")
            strObjPath = strTempPath + "main_behaviors/beta_menu2/"
            filetools.copyDirectory(self.path + "./exported/beta_menu2/",
                                    strObjPath)
            filetools.removeDirsQuiet(self.path + "exported/")

            # sub behaviors
            strObjPath = strTempPath + "behaviors/"
            filetools.copyDirectory(self.path + "../behaviors/", strObjPath)
            os.unlink(
                strObjPath +
                "standing/Pour regles de lancement des histoires, on met des heures afin de les ventiler dans le temps, le top serait selon les jours, mais comme mes demos sont souvent le lundi.txt"
            )

            # wait_anim
            strObjPath = strTempPath + "wait_anim/"
            strSrcPath = self.path + "../wait_anim/"
            # first export'em
            if (True):
                strPathBackup = os.getcwd()
                os.chdir(strSrcPath)
                os.system("convert_all_crg.py")
                os.chdir(strPathBackup)
            filetools.copyDirectory(strSrcPath + 'exported/', strObjPath)

            # modules
            strObjPath = strTempPath + "modules"
            bRet = filetools.copyDirectory(
                self.gitPath + "appu_modules/buildcc/%s/" % strNaoqiVersion,
                strObjPath)
            if (not bRet):
                print(
                    "ERR: LifeData.generatePackage: compiled module not found for the version of naoqi: '%s'"
                    % strNaoqiVersion)
                return False

            # preferences
            filetools.copyFile(
                self.gitPath + "appu_modules/src/autonomous/ALLife_sample.xml",
                strObjPath + "/ALLife_sample.xml")

            # naolibrary
            strObjPath = strTempPath + "naolibrary/"
            filetools.copyDirectory(
                self.gitPath + "appu_shared/library/naolibrary/", strObjPath)

            # scripts
            strObjPath = strTempPath + "scripts/"
            filetools.copyDirectory(self.path + "../scripts/", strObjPath)

            # bin
            strObjPath = strTempPath + "bin/"
            bRet = filetools.copyDirectory(
                self.gitPath +
                "appu_shared/scripts/cpp/buildcc/%s/lib" % strNaoqiVersion,
                strObjPath)
            if (not bRet):
                print(
                    "ERR: LifeData.generatePackage: compiled binary (watchdog or ...) not found for the version of naoqi: '%s'"
                    % strNaoqiVersion)
                return False

            # sounds
            if (not bForBehavior):
                strObjPath = strTempPath + "wav/"
                filetools.copyDirectory(self.gitPath + "appu_data/sounds/",
                                        strObjPath)

        strReleasePath = self.path + '/release/'
        if (not bForBehavior):
            filetools.removeDirsQuiet(strReleasePath)
            # light suppose you want to keep a previous generated
        filetools.makedirsQuiet(strReleasePath)

        strZipName = "life_data.zip"
        if (bForBehavior):
            strZipName = "life_data_light.zip"
        if (bRegenerateZip):
            # Create the big zip
            zf = zipfile.ZipFile(strReleasePath + strZipName, 'w',
                                 zipfile.ZIP_DEFLATED)
            # zf.write( 'temp/behaviors/metadata_samples.xml', 'behaviors/metadata_samples.xml' );
            filetools.addFolderToZip(zf, strTempPath)
            zf.close()
        if (not self.testPackage(strReleasePath + strZipName)):
            print("ERR: package '%s' is corrupted" %
                  (strReleasePath + strZipName))
            return False

        # copy metadata
        bRet = filetools.copyFile(self.path + "life_data__metadata.xml",
                                  strReleasePath + "metadata.xml")
        # copy minimal file to the project ressource
        strProjectPath = self.path + "install_life_behavior/ressources/"
        filetools.makedirsQuiet(strProjectPath)
        bRet &= filetools.copyFile(strTempPath + "python/" + "life_data.py",
                                   strProjectPath + "life_data.py")
        # copy from temp, so that it has a patched version number (when light)
        bRet &= filetools.copyDirectory(strTempPath + "python/abcdk",
                                        strProjectPath + "abcdk/")
        if (bForBehavior):
            bRet &= filetools.copyFile(strReleasePath + strZipName,
                                       strProjectPath + strZipName)
        return bRet
Exemple #4
0
        bRet = filetools.extractFolderFromZip(zf, aTableListPath)
        zf.close()

        # install preferences
        strALLifeSrc = strHome + "Applications/autonomous/modules/ALLife_sample.xml"
        strALLifeDst = strHome + "naoqi/preferences/ALLife.xml"
        if (not filetools.isFileExists(strALLifeDst)):
            try:
                bRet &= filetools.copyFile(strALLifeSrc, strALLifeDst)
            except BaseException, err:
                print(
                    "ERR: life_data.installPackage: copyfile %s => %s, err: %s"
                    % (strALLifeSrc, strALLifeDst, str(err)))
                # on continue la ou pas ?
        # install patch for launch module from every path
        filetools.makedirsQuiet(strHome + "naoqi/lib/naoqi/lib/")
        try:
            strFile = strHome + 'Applications/autonomous/modules/bin/usageremote'
            nCurrentMode = os.stat(strFile)[stat.ST_MODE]
            nNewMode = nCurrentMode | stat.S_IXGRP | stat.S_IEXEC
            os.chmod(strFile, nNewMode)
        except BaseException, err:
            print("ERR: LifeData.installPackage: chmod error: " + str(err))
        return bRet

    # installPackage - end

    def downloadPackage(self):
        if (not system.isOnNao()):
            print(
                "ERR: LifeData.downloadPackage: must be executed on a real Nao!"
    def generatePackage( self, strNaoqiVersion, bRegenerateTempFolder = True, bRegenerateZip = True, bForBehavior = False ):
        "generate the big archive containing all the life data"
        "return true if ok"
        "bForBehavior: to be used as ressources of a choregraphe project"
        print( "INF: LifeData.generatePackage( strNaoqiVersion = '%s' )" % strNaoqiVersion );
        if( system.isOnNao() ):
            print( "ERR: LifeData.generatePackage: must be executed on a computer within the git folder!" );
            return false;
        if( not bForBehavior ):
            strTempPath = self.path + 'temp_life_data/';
        else:
            strTempPath = self.path + 'temp_life_data_light/';
        if( bRegenerateTempFolder ):
            filetools.removeDirsQuiet( strTempPath );
            filetools.makedirsQuiet( strTempPath );
            
            # python script
            strObjPath = strTempPath + "python/";
            filetools.makedirsQuiet( strObjPath );
            filetools.copyDirectory( self.gitPath + "appu_shared/sdk/abcdk/", strObjPath + 'abcdk/', '.pyc' );
            filetools.copyFile( self.gitPath + "appu_work/altools.py", strObjPath + 'altools.py' );
            filetools.copyFile( self.gitPath + "appu_work/naoconfig.py.sample", strObjPath + 'naoconfig.py' );
            filetools.copyFile( self.gitPath + "appu_work/naolibrary.py", strObjPath + 'naolibrary.py' );
            filetools.copyFile( self.gitPath + "appu_work/behaviordata.py", strObjPath + 'behaviordata.py' );
            filetools.copyFile( self.gitPath + "appu_work/autonomous_pose_default.py", strObjPath + 'autonomous_pose_default.py' );
            filetools.copyFile( self.path + "life_data.py", strObjPath + 'life_data.py' );
            # update version:
            if( bForBehavior ):
                strFilename = strObjPath + 'life_data.py';
                rVersion = self.getFileVersion( strFilename );
                rVersionLight = rVersion - 0.001;
                strSkul = "rLifeDataVersionNumber = %g;";
                filetools.replaceInFile( strSkul % rVersion, strSkul % rVersionLight, strFilename );

            # main behaviors (exported to xar)
            strExportScript = self.gitPath + "appu_shared/scripts/python/convert_crg_into_new_xars.py";
            print( "INF: LifeData.generatePackage: launching script '%s'" % strExportScript );
            
            os.system( "python " + strExportScript + " " + ".." + " " + "autonomous2" );
            strObjPath = strTempPath + "main_behaviors/autonomous2/";
            filetools.copyDirectory( self.path + "./exported/autonomous2/", strObjPath );

            os.system( "python " + strExportScript + " " + self.gitPath + "appu_applications/beta_menu" + " " + "beta_menu2" );
            strObjPath = strTempPath + "main_behaviors/beta_menu2/";
            filetools.copyDirectory( self.path + "./exported/beta_menu2/", strObjPath );
            filetools.removeDirsQuiet( self.path + "exported/" );

            # sub behaviors
            strObjPath = strTempPath + "behaviors/";
            filetools.copyDirectory( self.path + "../behaviors/", strObjPath );
            os.unlink( strObjPath + "standing/Pour regles de lancement des histoires, on met des heures afin de les ventiler dans le temps, le top serait selon les jours, mais comme mes demos sont souvent le lundi.txt" );

            # wait_anim
            strObjPath = strTempPath + "wait_anim/";
            strSrcPath = self.path + "../wait_anim/";
            # first export'em
            if( True ):
                strPathBackup = os.getcwd();
                os.chdir( strSrcPath );
                os.system( "convert_all_crg.py" );
                os.chdir( strPathBackup );
            filetools.copyDirectory( strSrcPath + 'exported/', strObjPath );
            
            # modules
            strObjPath = strTempPath + "modules";
            bRet = filetools.copyDirectory( self.gitPath + "appu_modules/buildcc/%s/" % strNaoqiVersion, strObjPath );
            if( not bRet ):
                print( "ERR: LifeData.generatePackage: compiled module not found for the version of naoqi: '%s'" % strNaoqiVersion );
                return False;
                
            # preferences
            filetools.copyFile( self.gitPath + "appu_modules/src/autonomous/ALLife_sample.xml", strObjPath + "/ALLife_sample.xml" );

            # naolibrary
            strObjPath = strTempPath + "naolibrary/";
            filetools.copyDirectory( self.gitPath + "appu_shared/library/naolibrary/", strObjPath );
            
            # scripts
            strObjPath = strTempPath + "scripts/";
            filetools.copyDirectory( self.path + "../scripts/", strObjPath );

            # bin
            strObjPath = strTempPath + "bin/";
            bRet = filetools.copyDirectory( self.gitPath + "appu_shared/scripts/cpp/buildcc/%s/lib" % strNaoqiVersion, strObjPath );
            if( not bRet ):
                print( "ERR: LifeData.generatePackage: compiled binary (watchdog or ...) not found for the version of naoqi: '%s'" % strNaoqiVersion );
                return False;

            # sounds
            if( not bForBehavior ):
                strObjPath = strTempPath + "wav/";
                filetools.copyDirectory( self.gitPath + "appu_data/sounds/", strObjPath );

        strReleasePath = self.path + '/release/';
        if( not bForBehavior ):
            filetools.removeDirsQuiet( strReleasePath ); # light suppose you want to keep a previous generated
        filetools.makedirsQuiet( strReleasePath );

        strZipName = "life_data.zip";
        if( bForBehavior ):
            strZipName = "life_data_light.zip";
        if( bRegenerateZip ):
            # Create the big zip
            zf = zipfile.ZipFile( strReleasePath + strZipName, 'w', zipfile.ZIP_DEFLATED );
            # zf.write( 'temp/behaviors/metadata_samples.xml', 'behaviors/metadata_samples.xml' );
            filetools.addFolderToZip( zf, strTempPath );
            zf.close();
        if( not self.testPackage( strReleasePath + strZipName ) ):
            print( "ERR: package '%s' is corrupted" % (strReleasePath + strZipName) );
            return False;
        
        # copy metadata
        bRet = filetools.copyFile( self.path + "life_data__metadata.xml", strReleasePath + "metadata.xml" );        
        # copy minimal file to the project ressource
        strProjectPath = self.path + "install_life_behavior/ressources/" ;
        filetools.makedirsQuiet( strProjectPath );
        bRet &= filetools.copyFile( strTempPath + "python/" + "life_data.py", strProjectPath + "life_data.py" ); # copy from temp, so that it has a patched version number (when light)
        bRet &= filetools.copyDirectory( strTempPath + "python/abcdk", strProjectPath + "abcdk/" );
        if( bForBehavior ):
            bRet &= filetools.copyFile( strReleasePath + strZipName, strProjectPath + strZipName );
        return bRet;
     os.system( "killall usageremote" );
     
     bRet = filetools.extractFolderFromZip( zf, aTableListPath );
     zf.close();
     
     # install preferences
     strALLifeSrc = strHome + "Applications/autonomous/modules/ALLife_sample.xml";
     strALLifeDst = strHome + "naoqi/preferences/ALLife.xml";
     if( not filetools.isFileExists( strALLifeDst ) ):
         try:
             bRet &= filetools.copyFile( strALLifeSrc, strALLifeDst );
         except BaseException, err:
             print( "ERR: life_data.installPackage: copyfile %s => %s, err: %s" % ( strALLifeSrc, strALLifeDst, str( err ) ) );
             # on continue la ou pas ?
     # install patch for launch module from every path
     filetools.makedirsQuiet( strHome + "naoqi/lib/naoqi/lib/" );
     try:
         strFile = strHome + 'Applications/autonomous/modules/bin/usageremote';
         nCurrentMode =  os.stat(strFile)[stat.ST_MODE];
         nNewMode = nCurrentMode | stat.S_IXGRP | stat.S_IEXEC;
         os.chmod( strFile, nNewMode );
     except BaseException, err:
         print( "ERR: LifeData.installPackage: chmod error: " + str( err ) );
     return bRet;
 # installPackage - end
 
 def downloadPackage(self ):    
     if( not system.isOnNao() ):
         print( "ERR: LifeData.downloadPackage: must be executed on a real Nao!" );
         return false;        
     filetools.makedirsQuiet( self.strDownloadedPath );