detect_os() and unsupported OS

Vladimir Mihailenco avatarVladimir Mihailenco created an issue

Some commands are broken by detect_os() running on unsupported OS. For example:

    os = utils.detect_os()
    if os not in backports:
        fabric_utils.puts("Backports are not available for " + os)
        return

In such case detect_os() returns None (as it can not detect OS) and exception is raised:

TypeError: cannot concatenate 'str' and 'NoneType' objects

This can be fixed returning 'unknown' instead of None, or using string formatting:

fabric_utils.puts("Backports are not available for %s" % os)

Comments (3)

  1. Mikhail Korobov

    I think detect_os should even raise an exception if OS can't be detected because django-fab-deploy relies on OS detection and so it can to bad things if OS detection errors are surpassed.

    If developer is testing new OS he/she can set env.conf.OS variable to any value. This value will be returned by detect_os as-is. A patch with proper OS detection code can be submitted later in this case.

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.