Changeset - 21bdc2b39156
[Not reviewed]
0 1 0
Lance Edgar - 5 years ago 2019-09-23 15:25:39
lance@edbob.org
Add `postgresql.get_version()` function
1 file changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general) First comment
rattail_fabric2/postgresql.py
Show inline comments
 
@@ -25,6 +25,7 @@ Fabric Library for PostgreSQL
 
"""
 

	
 
import os
 
import re
 

	
 
from rattail_fabric2 import apt
 

	
 
@@ -36,6 +37,16 @@ def install(c):
 
    apt.install(c, 'postgresql')
 

	
 

	
 
def get_version(c):
 
    """
 
    Fetch the version of PostgreSQL running on the target system
 
    """
 
    result = c.run('psql --version', warn=True)
 
    if not result.failed:
 
        match = re.match(r'^psql \(PostgreSQL\) (\d+\.\d+)(?:\.\d+)?', result.stdout.strip())
 
        if match:
 
            return float(match.group(1))
 

	
 
def restart(c):
 
    """
 
    Restart the PostgreSQL database service
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now