~ajkavanagh/charms/trusty/memcached/add-spaces-support

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/osplatform.py

  • Committer: Jorge Niedbalski
  • Date: 2016-09-20 18:01:20 UTC
  • mfrom: (72.2.3 memcached.py3)
  • Revision ID: jorge.niedbalski@canonical.com-20160920180120-apb4ut3cugwxcrer
[freyes, r=niedbalski] Fixes bug LP: #1576458

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import platform
 
2
 
 
3
 
 
4
def get_platform():
 
5
    """Return the current OS platform.
 
6
 
 
7
    For example: if current os platform is Ubuntu then a string "ubuntu"
 
8
    will be returned (which is the name of the module).
 
9
    This string is used to decide which platform module should be imported.
 
10
    """
 
11
    tuple_platform = platform.linux_distribution()
 
12
    current_platform = tuple_platform[0]
 
13
    if "Ubuntu" in current_platform:
 
14
        return "ubuntu"
 
15
    elif "CentOS" in current_platform:
 
16
        return "centos"
 
17
    else:
 
18
        raise RuntimeError("This module is not supported on {}."
 
19
                           .format(current_platform))