Commits

Anonymous committed bfd7242

contl10n01: replace some more variables, don't use relative state.cfg, don't stop on mixed up sdf files, removed preparecws step

Comments (0)

Files changed (4)

l10ntools/scripts/tool/botctrl.py

         # TODO: read this state table from tool_cfg and not hardcoded
         # TODO: return next state from state so it is possible to switch on condition
         return dict({ 
-                        "START":      State(commands.Start(),     "PREPARECWS"),  
-                        "PREPARECWS": State(commands.PrepareCWS(),"PREBUILD"),
+                        "START":      State(commands.Start(),     "PREBUILD"),  
+                        #"PREPARECWS": State(commands.PrepareCWS(),"PREBUILD"),
                         "PREBUILD":   State(commands.PreBuild(),  "MERGE"),
                         "GETSDF":     State(commands.GetSdf(),    "MERGE"),
                         "MERGE":      State(commands.Merge(),     "COMPILE"),

l10ntools/scripts/tool/commands.py

 class Command:
     state_name = ""
     _log = None    
-    
+    state_config_location = ""
+
     def __str__(self):
         return "Command = "+str(self.state_name)
 
             state_cfg.add_section("Runtime") 
         state_cfg.set("Runtime", "current_state", self.state_name)
         
+        if Command.state_config_location == "":
+            Command.state_config_location = os.getcwd()+"/state.cfg"
+
         try:
-            #print "Writing to " +os.getcwd()+"/state.cfg"
-            fh = open("state.cfg","wb")
+            #print "Writing to " + Command.state_config_location
+            fh = open(Command.state_config_location, "wb")
             state_cfg.write(fh)
             fh.flush()
-            #fh.close()
-            #Command.i = Command.i+1
         except IOError:
             print "ERROR: Can not write file state.cfg!!!"
             sys.exit(-1)
         self._server_path = tool_cfg.get("Download Server", "server_path")
         self._ftp_server_url  = tool_cfg.get("Download Server", "ftp_server_url") 
         self._ftp_server_path = tool_cfg.get("Download Server", "ftp_server_path")
-        self._dest_path   = tool_cfg.get("Download Server", "dest_path")
+        self._dest_path = utils.Util.replace_variables(tool_cfg.get("Download Server", "dest_path"), env, tool_cfg, self._log)  
         self._server_user = tool_cfg.get("Download Server", "server_user")
         self._server_keyfile = tool_cfg.get("Download Server", "server_keyfile")
         self._ftp_server_user = tool_cfg.get("Download Server", "ftp_server_user")
         self._ftp_server_keyfile = tool_cfg.get("Download Server", "ftp_server_keyfile")
         #self._filesystem   = tool_cfg.get("Download Server", "filesystem")
-        self._unzip =  tool_cfg.get("Download Server", "unzip")
+        self._unzip =   utils.Util.replace_variables(tool_cfg.get("Download Server", "unzip"), env, tool_cfg, self._log)  
         self._log = log 
         
     def do(self, env):
         [utils.Util.rm(file, self._log) for file in glob.glob(self._dest_path + "/*_err.sdf")]
         self._log.info("Gsichecking ...")
         # TODO: Do we want -l -k here ?
-        [utils.Util.exe_ignore_errors(self._cws_root + "/solenv/bin/gsicheck -l none -k -wc " + file, self._log, env, True) 
+        [utils.Util.exe_ignore_errors(self._cws_root + "/solenv/bin/gsicheck -l none -k -wc -we " + file, self._log, env, True) 
                 for file in glob.glob(self._dest_path + "/*.sdf") if not file.endswith("_ok.sdf")] 
         files = glob.glob(self._dest_path + "/*_ok.sdf")
         for file in files:
                     utils.Util.rename(target_file, target_file + "_tmp", self._log)
                     src_file = self._cws_root + "/" + self._lic_header
                     utils.Util.copyfile(src_file, target_file, self._log)
-                    #self._log.debug("DBG: Appending to " + target_file) 
                     try:
                         f = open(target_file, "a+") 
                         for value in mylist:
                     else:
                         f.close()
             else:
-                self._log.die("The sdf file "+str(file)+" contains the languages "+str(langs)+". And now what?")                
+                self._log.warning("The sdf file "+str(file)+" contains the languages "+str(langs)+". Skipping it!")                
 
     def test_on_changes(self):
         myui = ui.ui()
         repo = hg.repository(myui, self._cws_root + "/" )
         ### hg add ###
         if len(self._new_files) > 0:
-            add_list
+            add_list = []
             for lang in self._new_files:
                 add_list.append(self._cws_root+"/l10n/source/"+lang+"/localize.sdf")
             add_errmsg = "Execution failed of hg add files " + str(" ".join(add_list)) + "'\n"
         # Start build
         start_time = time.time()
         p = utils.Util.exe_no_blocking("perl "+self._cws_root + "/solenv/bin/build.pl product=full " + procs + " --all", self._log, env)      
-
+        
         # Start the stdout / stderr reader
         t = TReaderControl(p, b_stats, self._log)
         t.start()
-        
+        os.chdir(old_path)
+
         # Process running
         while p.poll() == None:               
             time.sleep(1)
             milestone = eisc.get_current_milestone(env["WORK_STAMP"])
 
         state_cfg.set("Runtime", "milestone", milestone)
-        work_stamp = tool_cfg.get("HG","work_stamp")
+        work_stamp = utils.Util.replace_variables(tool_cfg.get("HG","work_stamp"), env, tool_cfg, self._log)
+
         env["WORK_STAMP"] = work_stamp
         self._log = log
         self.prepare_env(tool_cfg, state_cfg, env)#, milestone, tool_cfg.get("HG","work_stamp"))
-        self._repo_master = tool_cfg.get("HG","repo_master_url")
+        #self._repo_master = tool_cfg.get("HG","repo_master_url")
         state_cfg.set("Runtime", "milestone", milestone)
         self._cws_create_string = utils.Util.replace_variables(tool_cfg.get("CWS","cws_create_string"), env, tool_cfg, self._log)
         self._cws_create_string = self._cws_create_string.replace(env["WORK_STAMP"],env["WORK_STAMP"].lower())

l10ntools/scripts/tool/contl10n.py

     def init_state_table(self):
         if BotController.is_mainbot():
             self._state_table = dict({ 
-                            "START":    State(Start(),     "PREPARECWS"),  
-                            "PREPARECWS": State(PrepareCWS(), "PREBUILD"),
+                            "START":    State(Start(),     "PREBUILD"),  
+                            #"PREPARECWS": State(PrepareCWS(), "PREBUILD"),
                             "PREBUILD": State(PreBuild(),  "GETSDF"),
                             "GETSDF":   State(GetSdf(),    "MERGE"),
                             "MERGE":    State(Merge(),     "COMPILE"),

l10ntools/scripts/tool/utils.py

     
     def die(self, text):
         #self._bot_model.set_state(ContL10nStatus.HAS_ERROR)
-        #self._bot_model.contl10n_status = "HAS_ERROR" # fix me!!!!!!!!!!!!!!!!
+        #self._bot_model.contl10n_status = "HAS_ERROR" 
         #self._bot_model.set_hint(text)
         self.log.critical(text)
         Util.send_mail(text, "Contl10n bot error", self)
         """ Delegate access to implementation """
         return setattr(self.__instance, attr, value)
  
-#class EisWrapper():
-#    
-#    eis = None
-#    
-#    @staticmethod
-#    def init(url, namespace, username=None, password=None):
-#        EisWrapper.eis = Eis.get_eis(url, namespace, username=None, password=None)
-#        
-#    @staticmethod
-#    def getId(cws_name):  
-#        cws_id = con.getChildWorkspaceId(cws_name)
-#        if EisWrapper.is_valid(cws_id, "id", cws_name): 
-#            return cws_id
-#
-#    @staticmethod
-#    def is_valid(value, value_name, cws):
-#        if not isinstance(value, str) or len(value) == 0:
-#                raise eis.EisError("can't retrieve cws %s for cws %s" % value_name, cws)
-#        return True
+