예제 #1
0
    def get():
        sys.path.append(path.lib_exa)
        from version import version as release

        # transitional fix
        if "-" in release:
            release = release.split("-")[0]

        if version.changelog() != release:
            release += ".post1"

        return release
예제 #2
0
def checkUpdate(config, mode):
    github_branch, devSkipVersionCheck, devIcMode, upgradeOnStart = setDevFunctions(
        config)
    doICUpdate = False
    normalUpdate = False
    if devSkipVersionCheck == True:
        logging.warning(
            "Version check skipping mode enabled, skipping version checking.")
    else:
        if devIcMode:
            logging.info("Development commit update mode.")
            response = requests.get(
                "https://api.github.com/repos/mrkakisen/nafsdm/branches/development"
            )
            if (response.status_code == requests.codes.ok):
                data = response.json()
                latestCommit = data["commit"]["sha"][0:7]
                if version.split("-")[0] == latestCommit:
                    logging.info("You're using the latest development commit!")
                else:
                    doICUpdate = True
                    logging.info(
                        "A new update is available (dev commit - my version: "
                        + version + " - latest version: " + latestCommit +
                        "-dev)")
            else:
                logging.critical("Failed to establish connection to GitHub.")
                gracefulExit(1)
        else:
            logging.info("Checking for new versions..")
            r = requests.get(
                "https://raw.githubusercontent.com/MrKaKisen/nafsdm/" +
                github_branch + "/version.txt")

            # check if we got a good code, requests has builtin codes which are OK
            if (r.status_code == requests.codes.ok):
                if (r.text.split("\n")[0] == version):
                    logging.info("You're running the latest version, " +
                                 version + "!")
                else:
                    logging.info(
                        "There is a new version available! New version: " +
                        r.text.split("\n")[0])
                    normalUpdate = True

        if normalUpdate == True or doICUpdate == True:
            if upgradeOnStart or mode == "cli":
                if (os.path.exists("/home/slave-nafsdm/tempUpgrade")):
                    logging.warning("Temp upgrade folder already exists!")
                else:
                    os.makedirs("/home/slave-nafsdm/pythondaemon/tempUpgrade")
                    # shortcut to make the shit importable
                    f = open(
                        "/home/slave-nafsdm/pythondaemon/tempUpgrade/__init__.py",
                        "w")
                    f.write(" ")
                    f.close()

                # url must change from development to master before release!!
                url = ("https://raw.githubusercontent.com/MrKaKisen/nafsdm/" +
                       github_branch + "/scripts/upgradeSlave.sh")
                r = requests.get(url)
                if (r.status_code == requests.codes.ok):
                    f = open(
                        "/home/slave-nafsdm/pythondaemon/tempUpgrade/temp_upgrade.sh",
                        "w")
                    f.write(r.content)
                    f.close()
                    import subprocess
                    outputNull = subprocess.check_output([
                        "chmod", "+x",
                        "/home/slave-nafsdm/pythondaemon/tempUpgrade/temp_upgrade.sh"
                    ])

                    url = (
                        "https://raw.githubusercontent.com/MrKaKisen/nafsdm/" +
                        github_branch + "/scripts/upgradeSlave.py")
                    r = requests.get(url)
                    if (r.status_code == requests.codes.ok):
                        f = open(
                            "/home/slave-nafsdm/pythondaemon/tempUpgrade/temp_upgrade.py",
                            "w")
                        f.write(r.content)
                        f.close()
                        import subprocess
                        outputNull = subprocess.check_output([
                            "chmod", "+x",
                            "/home/slave-nafsdm/pythondaemon/tempUpgrade/temp_upgrade.py"
                        ])

                        from tempUpgrade.temp_upgrade import initUpgrade
                        if doICUpdate:
                            upgradeStatus = initUpgrade(
                                config, github_branch, True)
                        else:
                            upgradeStatus = initUpgrade(
                                config, github_branch, False)
                        if upgradeStatus == "exception":
                            logging.critical(
                                "An error occured during upgrade. The script probably failed mid-through (that would break your installation). Please retry or run the script manually."
                            )
                            gracefulExit(1)
                        elif upgradeStatus == "unsupported":
                            logging.warning(
                                "You're running an unsupported version - nafsdm will not be able to upgrade."
                            )
                            logging.warning(
                                "Consider enabling skip version checking.")
                            logging.info("nafsdm will continue boot")
                        elif upgradeStatus == "unknownException":
                            logging.critical(
                                "Unknown exception occured during upgrade.")
                            gracefulExit(1)
                        else:
                            f = open("/home/slave-nafsdm/upgradeLog.log", "w")
                            f.write(upgradeStatus)
                            f.close()
                            logging.info(
                                "Upgrade completed. Make sure no additional adjustments are required for this particular upgrade."
                            )
                            logging.info(
                                "Upgrade log is available at /home/slave-nafsdm/upgradeLog.log"
                            )
                            if mode == "cli":
                                logging.info(
                                    "Upgrade command was sent from CLI. Restarting nafsdm-slave.."
                                )
                                try:
                                    output = subprocess.check_output([
                                        "/bin/systemctl", "restart",
                                        "nafsdm-slave.service"
                                    ])
                                except Exception:
                                    logging.exception(
                                        "An error occured during systemd restart."
                                    )
                                    logging.error(
                                        "Exit due to previous error.")
                                    gracefulExit(1)
                            else:
                                gracefulExit(0)
                    else:
                        logging.critical(
                            "Failed to establish connection to GitHub.")
                        gracefulExit(1)
                else:
                    logging.critical(
                        "Failed to establish connection to GitHub.")
                    gracefulExit(1)
            else:
                logging.info(
                    "Upgrade on start is disabled - nafsdm will not perform upgrade."
                )
                logging.info(
                    "It is recommended to upgrade as soon as possible using 'nafscli upgrade'"
                )
예제 #3
0
master_doc = 'index'

# General information about the project.
project = u'ownpaste'
copyright = u'2012-2013, Rafael G. Martins'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

cwd = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(cwd, '..', 'ownpaste'))
from version import version as release

# The short X.Y version.
version = release.split('+')[0]
version = release.split('pre')[0]

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
예제 #4
0
def checkUpdate():
    normalUpdate = False
    doICUpdate = False
    if devStatus == True:
        log("Developer mode enabled, skipping version checking.")
    else:
        if devIcMode:
            log("Development commit update mode.")
            response = requests.get(
                "https://api.github.com/repos/mrkakisen/nafsdm/branches/development"
            )
            if (response.status_code == requests.codes.ok):
                data = response.json()
                latestCommit = data["commit"]["sha"][0:7]
                if version.split("-")[0] == latestCommit:
                    log("You're using the latest development commit!")
                else:
                    doICUpdate = True
                    log("A new update is available (dev commit - my version: "
                        + version + " - latest version: " + latestCommit +
                        "-dev)")
            else:
                log("FATAL: Couldn't connect to GitHub! Quitting...")
                exit(1)
        else:
            log("Checking if a new version is available..")
            r = requests.get(
                "https://raw.githubusercontent.com/MrKaKisen/nafsdm/" +
                github_branch + "/version.txt")

            # check if we got a good code, requests has builtin codes which are OK
            if (r.status_code == requests.codes.ok):
                if (r.text.split("\n")[0] == version):
                    log("You're running the latest version, " + version + "!")
                    normalUpdate = False
                else:
                    log("NOTICE: There is a new version available! New version: "
                        + r.text.split("\n")[0])
                    normalUpdate = True

        if normalUpdate == True or doICUpdate == True:
            if (os.path.exists("/home/master-nafsdm/tempUpgrade")):
                log("WARN: folder already exists?")
            else:
                os.makedirs("/home/master-nafsdm/pythondaemon/tempUpgrade")
                # shortcut to make the shit importable
                f = open(
                    "/home/master-nafsdm/pythondaemon/tempUpgrade/__init__.py",
                    "w")
                f.write(" ")
                f.close()

            url = ("https://raw.githubusercontent.com/MrKaKisen/nafsdm/" +
                   github_branch + "/scripts/upgradeMaster.sh")
            r = requests.get(url)
            if (r.status_code == requests.codes.ok):
                f = open(
                    "/home/master-nafsdm/pythondaemon/tempUpgrade/temp_upgrade.sh",
                    "w")
                f.write(r.content)
                f.close()
                import subprocess
                outputNull = subprocess.check_output([
                    "chmod", "+x",
                    "/home/master-nafsdm/pythondaemon/tempUpgrade/temp_upgrade.sh"
                ])

                url = ("https://raw.githubusercontent.com/MrKaKisen/nafsdm/" +
                       github_branch + "/scripts/upgradeMaster.py")
                r = requests.get(url)
                if (r.status_code == requests.codes.ok):
                    f = open(
                        "/home/master-nafsdm/pythondaemon/tempUpgrade/temp_upgrade.py",
                        "w")
                    f.write(r.content)
                    f.close()
                    import subprocess
                    outputNull = subprocess.check_output([
                        "chmod", "+x",
                        "/home/master-nafsdm/pythondaemon/tempUpgrade/temp_upgrade.py"
                    ])

                    from tempUpgrade.temp_upgrade import initUpgrade
                    if doICUpdate:
                        upgradeStatus = initUpgrade(github_branch, True)
                    else:
                        upgradeStatus = initUpgrade(github_branch, False)
                    if upgradeStatus == "exception":
                        log("FATAL: An error occured during upgrade. The script probably failed mid-through (that would break your installation). Please retry or run the script manually."
                            )
                        exit(1)
                    elif upgradeStatus == "unsupported":
                        log("WARNING: You're running an unsupported version - nafsdm will not be able to upgrade."
                            )
                        log("WARNING: Consider using developer mode to skip version checking."
                            )
                    elif upgradeStatus == "unknownException":
                        log("Unknown exception occured during upgrade.")
                        exit(1)
                    else:
                        f = open("/home/master-nafsdm/upgradeLog.log", "w")
                        f.write(upgradeStatus)
                        f.close()
                        log("Upgrade completed. Make sure no additional adjustments are required for this particular upgrade."
                            )
                        log("Upgrade log is available at /home/master-nafsdm/upgradeLog.log"
                            )
                        exit(0)
                else:
                    log("FATAL: Failed to establish connection to GitHub.")
                    exit(1)
            else:
                log("FATAL: Failed to establish connection to GitHub.")
                exit(1)
예제 #5
0
파일: conf.py 프로젝트: RMCampos/blohg
master_doc = 'index'

# General information about the project.
project = 'blohg'
copyright = '2010-2013, Rafael G. Martins'

cwd = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(cwd, '..', 'blohg'))
from version import version as release

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = release.split('+')[0]
# The full version, including alpha/beta/rc tags.
#release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
예제 #6
0
 def _check_versions(self, daemon_version):
     lMayor, lMinor, lPatch = version.split(".")
     rMayor, rMinor, rPatch = daemon_version.split(".")
     if lMayor != rMayor or (lMayor == rMayor and lMinor != rMinor):
         self._version_warning_trigger.emit(daemon_version, version)
예제 #7
0
    def run(self):
        qh = logging.handlers.QueueHandler(self.logging_queue)
        logger = logging.getLogger()
        logger.setLevel(self.loggerLevel)
        logger.addHandler(qh)
        logging.getLogger("socketio.client").setLevel(30)
        logging.getLogger("engineio.client").setLevel(30)
        _sockMgr = self
        info = {'version': version.split('-')[0], 'socket_guid': self.guid, 'name': self.characterName}
        peld_check_data = {'socket_guid': self.guid, 'name': self.characterName}

        class Namespace(socketio.ClientNamespace):
            def on_connect(self):
                logger.info('Connected websocket to ' + _sockMgr.server)

            def on_disconnect(self):
                _sockMgr.socket.disconnect()
                logger.info('Websocket disconnected from ' + _sockMgr.server)

            def on_client_registered(self, *args):
                logger.info('Websocket client registered with server')
                _sockMgr.loginNotificationQueue.put(True)
                _sockMgr.registered = True
            
            def on_peld_check(self, data):
                data = json.loads(data)
                _sockMgr.fleetMetadataQueue.put(data)
            
            def on_peld_data(self, data):
                data = json.loads(data)
                if data['category'] in ['dpsOut', 'dpsIn', 'logiOut']:
                    _sockMgr.dataRecieveQueue.put(data)
            
            def on_peld_error(self, data):
                _sockMgr.errorQueue.put(data)

        webbrowser.open(self.server + self.loginArgs)
        while self.running:
            try:
                self.registered = False
                self.socket = socketio.Client(ssl_verify=False)
                self.socket.register_namespace(Namespace('/client'))
                self.socket.connect(self.server, namespaces=['/client'])
                while not self.registered:
                    self.socket.emit('register_client', info, namespace='/client')
                    self.socket.sleep(1)
                timeWaiting = 30.0
                while self.running:
                    while not self.dataQueue.empty():
                        peld_data = self.dataQueue.get()
                        peld_data['entry']['owner'] = self.characterName
                        peld_data['socket_guid'] = self.guid
                        self.socket.emit('peld_data', peld_data, namespace='/client')
                    self.socket.sleep(0.1)
                    timeWaiting += 0.1
                    if timeWaiting >= 30:
                        self.socket.emit('peld_check', peld_check_data, namespace='/client')
                        timeWaiting = 1
            except Exception as e:
                logger.exception(e)
            except:
                logger.critical('baseException')
예제 #8
0
파일: conf.py 프로젝트: GoGoBunny/blohg
master_doc = "index"

# General information about the project.
project = u"blohg"
copyright = u"2010-2013, Rafael G. Martins"

cwd = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(cwd, "..", "blohg"))
from version import version as release

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = release.split("+")[0]
# The full version, including alpha/beta/rc tags.
# release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
예제 #9
0
파일: utils.py 프로젝트: shortv/opensnitch
 def check_versions(daemon_version):
     lMayor, lMinor, lPatch = version.split(".")
     rMayor, rMinor, rPatch = daemon_version.split(".")
     return lMayor != rMayor or (lMayor == rMayor and lMinor != rMinor)