Merge "housekeeping: Switch to pytho2 and handle version" from Amnon

This series handle two issues:
* Moving to python2, though python3 is supported, there are modules that we
  need that are not rpm installable, python3 would wait when it will be more
  mature.

* Check version should send the current version when it check for a new one and
  a simple string compare is wrong.
This commit is contained in:
Avi Kivity
2016-07-31 14:55:36 +03:00
3 changed files with 15 additions and 11 deletions

View File

@@ -30,7 +30,7 @@ URL: http://www.scylladb.com/
BuildRequires: libaio-devel libstdc++-devel cryptopp-devel hwloc-devel numactl-devel libpciaccess-devel libxml2-devel zlib-devel thrift-devel yaml-cpp-devel lz4-devel snappy-devel jsoncpp-devel systemd-devel xz-devel openssl-devel libcap-devel libselinux-devel libgcrypt-devel libgpg-error-devel elfutils-devel krb5-devel libcom_err-devel libattr-devel pcre-devel elfutils-libelf-devel bzip2-devel keyutils-libs-devel xfsprogs-devel make gnutls-devel systemd-devel lksctp-tools-devel protobuf-devel protobuf-compiler
%{?fedora:BuildRequires: boost-devel ninja-build ragel antlr3-tool antlr3-C++-devel python3 gcc-c++ libasan libubsan python3-pyparsing dnf-yum}
%{?rhel:BuildRequires: scylla-libstdc++-static scylla-boost-devel scylla-ninja-build scylla-ragel scylla-antlr3-tool scylla-antlr3-C++-devel python34 scylla-gcc-c++ >= 5.1.1, python34-pyparsing}
Requires: scylla-conf systemd-libs hwloc collectd PyYAML python-urwid pciutils
Requires: scylla-conf systemd-libs hwloc collectd PyYAML python-urwid pciutils python-pyparsing python-requests
Conflicts: abrt
%description server

View File

@@ -16,7 +16,7 @@ Conflicts: scylla-server (<< 1.1)
Package: scylla-server
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, hwloc-nox, collectd, scylla-conf, python-yaml, python-urwid, python3-requests, @@DEPENDS@@
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, hwloc-nox, collectd, scylla-conf, python-yaml, python-urwid, python-requests, @@DEPENDS@@
Description: Scylla database server binaries
Scylla is a highly scalable, eventually consistent, distributed,
partitioned row DB.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/python
#
# Copyright (C) 2016 ScyllaDB
#
@@ -19,11 +19,14 @@
# You should have received a copy of the GNU General Public License
# along with Scylla. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import print_function
import argparse
import json
import urllib
import urllib2
import requests
from pkg_resources import parse_version
VERSION = "1.0"
quiet = False
@@ -40,24 +43,25 @@ def help(args):
parser.print_help()
def get_json_from_url(path):
req = urllib.request.Request(path)
req = urllib2.Request(path)
try:
response = urllib.request.urlopen(req)
response = urllib2.urlopen(req)
data = response.read()
encoding = response.info().get_content_charset('utf-8')
return json.loads(data.decode(encoding))
except urllib.error.URLError as e:
return json.loads(data)
except urllib2.URLError as e:
pass
return ""
def get_api(path):
return get_json_from_url("http://localhost:10000" + path)
def version_compare(a, b):
return parse_version(a) < parse_version(b)
def check_version(ar):
current_version = get_api('/storage_service/scylla_release_version')
latest_version = get_json_from_url(version_url)["version"]
if current_version != latest_version:
latest_version = get_json_from_url(version_url + "?version=" + current_version)["version"]
if version_compare(current_version, latest_version):
traceln("A new version was found, current version=", current_version, " latest version=", latest_version)
parser = argparse.ArgumentParser(description='ScyllaDB help report tool', conflict_handler="resolve")