Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.

Commit

Permalink
finish update, close #9
Browse files Browse the repository at this point in the history
  • Loading branch information
h4llow3En committed Nov 6, 2015
1 parent dfd123e commit bb1ac9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def install(mute=True):

def uninstall():
print('Uninstall tdo...')
subprocess.call([sys.argv[0], 'install', '--record', 'files.txt'])
subprocess.call(['python3', sys.argv[0], 'install', '--record', 'files.txt'])
filelist = []
with open('files.txt') as files:
filelist = files.readlines()
Expand Down
17 changes: 14 additions & 3 deletions tdo/todolist/maintenance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
import json
import shutil
import subprocess
import urllib.request
from .persistence import home, jsonfile, settingsfile
Expand Down Expand Up @@ -38,15 +39,25 @@ def update():
repo = 'tdo'
output = subprocess.getoutput('curl -s https://api.github.com/repos/\
{user}/{repo}/releases'.format(user=user, repo=repo))
linklist = re.search(r'"browser_download_url": "(https\:\/\/.*\.zip)"',
linklist = re.search(r'"zipball_url": "(https\:\/\/.*)"',
output)
try:
link = linklist.group(1)
with urllib.request.urlopen(link) as resp, open('download.zip', 'wb') as f:
with urllib.request.urlopen(link) as resp, open('dl.zip', 'wb') as f:
data = resp.read()
f.write(data)
import zipfile
with zipfile.ZipFile('download.zip', "r") as z:
with zipfile.ZipFile('dl.zip', "r") as z:
z.extractall(".")
os.remove('dl.zip')
newdir = '.'
for entry in os.listdir():
if re.match(r'Feliix42\-tdo\-.*', entry):
newdir = entry
os.chdir(newdir)
subprocess.call(['python3', './setup.py', 'install'])
os.chdir('..')
shutil.rmtree(newdir)

except AttributeError:
print('No release available')

0 comments on commit bb1ac9a

Please sign in to comment.