Skip to content

Instantly share code, notes, and snippets.

@tombasche
Last active November 4, 2016 08:03
Show Gist options
  • Save tombasche/ebefdf587d33fa0412cf66a453b177a0 to your computer and use it in GitHub Desktop.
Save tombasche/ebefdf587d33fa0412cf66a453b177a0 to your computer and use it in GitHub Desktop.
Dronever
#inspired by http://cube-drone.com/comics/c/version-sacrifice
# note: you'll need to pip install pygithub
import time
import urllib2
import random
from github import Github
def nvl(var, val):
if var is None:
return val
return var
def getWord():
word_site = "http://www.math.sjsu.edu/~foster/dictionary.txt"
response = urllib2.urlopen(word_site)
txt = response.read()
wordlist = txt.splitlines()
return random.choice(wordlist)
def getVersionNumber(major, mood, repoName):
g = Github("username", "password") # replace with your own
if repoName is not None:
repo = g.get_user().get_repo(repoName)
issueCount = str(nvl(repo.get_issues(state='open').totalCount, 0))
forkCount = nvl(repo.get_forks().totalCount, 0)
stars = nvl(repo.get_stargazers().totalCount, 0)
timestamp = str(time.time())
word = getWord()
forkStars = str(forkCount + stars)
return str(major) + "." + mood + "." + issueCount + "." + (forkStars) + "." + word + "." + timestamp + ".7"
print getVersionNumber(4, 'relieved', 'reponame')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment