Commits

Nik Cubrilovic committed 2897e1d

updater support

Comments (0)

Files changed (6)

 	./bin/write_version
 	VERSION=$(shell cat VERSION)
 	git add VERSION
-	@git ci -m "${VERSION}"
-	git tag ${VERSION}
+	@git ci -m "`cat VERSION`"
+	git tag `cat VERSION`
 	git push origin --all
 	git push bb --all
 	python setup.py publish
 
 clean:
-	find . -name *.pyc -exec rm -f {} \;
+	find . -name *.pyc -exec rm -f {} \;
+
 
 If you have previously installed cexbot you will need to run an upgrade:
 
- `pip -U install cexbot`
+ `pip install -U cexbot`
 
 ## Dev Install
 
 
   `cexbot-cli config --testauth`
 
-## Usage
+## Usage and Help
 
- see
+see
 
-  `./cexbot-cli -h`
+  `cexbot-cli -h`
 
 new features being added all the time.
 
-  see
-
-  `./cexbot-cli listtasks`
-
-
 ## Update
 
 Update frequently, new features being added all the time.

bin/write_version

 #!/bin/bash
 PP=`which python`
-$PP -c "import cexbot; cexbot.write_version()"
+$PP -c "import cexbot; cexbot.write_version(semantic=True)"

cexbot/__init__.py

 import sys
 import os
 
-VERSION = (0, 0, 11, 'alpha', 1)
+VERSION = (0, 0, 13, 'alpha', 1)
 
 __clsname__ = 'cexbot'
 __author__ = 'Nik Cubrilovic <nikcub@gmail.com>'
 __copyright__ = 'Copyright (c) 2013, Nik Cubrilovic. All rights reserved.'
 
 
-def get_version(version=None):
+def get_version(version=None, semantic=False):
   if version is None:
     version = VERSION
   assert version[3] in ('alpha', 'beta', 'rc', 'final')
   elif version[3] != 'final':
     mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
     sub = mapping[version[3]] + str(version[4])
-  return main + sub
+  if not semantic:
+    return main + sub
+  else:
+    return main + '-' + sub
 
 def get_status(version=None):
   if version is None:
   assert version[3] in ('alpha', 'beta', 'rc', 'final')
   return version[3]
 
-def write_version(file_path=None):
+def write_version(file_path=None, semantic=False):
   if not file_path:
     if not '__file__' in globals():
       cwd = os.path.abspath(os.getcwd())
   version_file = os.path.join(file_path, 'VERSION')
   print file_path
   with open(version_file, 'w') as f:
-    f.write(get_version())
+    f.write(get_version(semantic=semantic))
 
 def get_git_changeset():  # pragma: nocover
   """Returns a numeric identifier of the latest git changeset.

cexbot/updater.py

 import cexbot
 import logging
 # @TODO find a non-brainded semver implementation
-# import semantic_version
+import semantic_version
 
 UPDATE_URL = "https://raw.github.com/nikcub/cexbot/master/VERSION"
 
 		return False
 
 def check_update():
-	cur_version = cexbot.get_version()
+	cur_version = cexbot.get_version(semantic=True)
 	latest_version = get_latest()
-	logging.info("Current version: %s Latest version: %s" % (cur_version, latest_version))
-	# if latest_version:
-		# lv = semantic_version.Version(latest_version)
-		# cv = semantic_version.Version(cur_version)
-		# if lv > cv:
-			# logging.error("New version available, run git pull or pip -U cexbot")
+	print "Current version: %s Latest version: %s" % (cur_version, latest_version)
+	if latest_version:
+		lv = semantic_version.Version(latest_version)
+		cv = semantic_version.Version(cur_version)
+		if lv > cv:
+			logging.error("New version available, run git pull or pip -U cexbot")
 	return None
 scripts = ['bin/cexbot']
 packages = [
   'requests',
+  'semantic_version'
 ]
 
 package_dir = os.path.realpath(os.path.dirname(__file__))