Repository: fastmonkeys/stellar

Issue:
ValueError: invalid literal for int() with base 10: '6beta1'
Related to following issue: #67 
I'm using Postgres 9.6beta1 on Linux.
The error happens when I try to take a snapshot.

Discussion:

Patch:
diff --git a/stellar/operations.py b/stellar/operations.py
index d1394ea..e5ba60d 100644
--- a/stellar/operations.py
+++ b/stellar/operations.py
@@ -1,4 +1,5 @@
 import logging
+import re
 
 import sqlalchemy_utils
 
@@ -27,7 +28,7 @@ def get_engine_url(raw_conn, database):
 def _get_pid_column(raw_conn):
     # Some distros (e.g Debian) may inject their branding into server_version
     server_version = raw_conn.execute('SHOW server_version;').first()[0]
-    version_string, _, _ = server_version.partition(' ')
+    version_string = re.search('^(\d+\.\d+)', server_version).group(0)
     version = [int(x) for x in version_string.split('.')]
     return 'pid' if version >= [9, 2] else 'procpid'
 


Test patch:
diff --git a/tests/test_operations.py b/tests/test_operations.py
index 2f6d7d3..62b1e2e 100644
--- a/tests/test_operations.py
+++ b/tests/test_operations.py
@@ -21,7 +21,7 @@ class TestGetPidColumn(object):
         assert _get_pid_column(raw_conn) == 'procpid'
 
     @pytest.mark.parametrize('version', [
-        '9.2', '9.3', '10.0', '9.2.1', '10.1.1',
+        '9.2', '9.3', '10.0', '9.2.1', '9.6beta1', '10.1.1',
         '10.3 (Ubuntu 10.3-1.pgdg16.04+1)'
     ])
     def test_returns_pid_for_version_equal_or_newer_than_9_2(self, version):