Example #1
0
    def runWin(self):
        self.logger.debug("Update runWin")
        self.download()

        sysInfo = globalProperty.getSysInfo()
        if re.match(".*windows.*\s+vista\s+.*", sysInfo.os.lower()) or re.match(
            ".*windows.*\s+7\s+.*", sysInfo.os.lower()
        ):
            self.logger.info(
                "Windows Vista and Windows 7 do not support AT command, so to activate QMS need reboot your machine"
            )
            from RebootOS import childTask

            rebootOS = childTask("rebootOS", self.priority + 1)
            rebootOS.addPara("timeLength", 60)
            rebootOS.run()
        else:
            os.system("at %d:%d /interactive %s" % (self.when.hour, self.when.minute, self.QMSGateLocation))
            # sys.exit doesn't work?
            # os.abort()
            self.logger.info("restAdm will be restared after 120 seconds")
        time.sleep(10)
        os._exit(0)
Example #2
0
    def reload(self):
        # allModuleArray = sys.modules.iteritems()
        allModuleArray = sys.modules.values()
        for module in allModuleArray:
            # self.logger.debug('added module %s' % m)
            filename = getattr(module, "__file__", None)
            if filename and filename != __file__ and filename.find("restAdm") == -1:
                if not os.path.exists(filename):
                    continue
                if filename.endswith(".pyc") or filename.endswith(".pyo"):
                    filename = filename[:-1]
                if filename.startswith(os.getcwd()) and os.path.exists(filename):
                    try:
                        self.logger.debug("reloaded module %s" % filename)
                        reload(module)
                    except Exception, e:
                        self.logger.warning(e)


##################This section is mainly for debug -- Begin #############################
if __name__ == "__main__":
    u = childTask("TestUpdates", 1)
    u.runWin()
"""
    if not u.isQMSGateExist():
        u.getQMSGate()
    u.when = datetime.datetime.now()
    u.when += datetime.timedelta(seconds=120)
    os.system('at %d:%d /interactive %s' % (u.when.hour, u.when.minute, u.QMSGateLocation))
"""