Skip to content

Commit

Permalink
added install script (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiweiang committed Jan 13, 2017
1 parent d1211c2 commit 14c10aa
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions install_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from urllib.request import urlopen
from sys import platform as _platform
import os

def download_txt_url(path_to_file, url):
with urlopen(url) as stream:
CHUNK = 2 ** 14
with open(path_to_file, 'wb') as outfile:
while True:
chunk = stream.read(CHUNK)
if not chunk:
break
outfile.write(chunk)


if _platform == "linux" or _platform == "linux2" or _platform == "darwin":
bin_shi7en = 'ninja_shi7_linux'
bin_split = 'gotta_split_s_linux'
elif _platform == "darwin":
bin_shi7en = 'ninja_shi7_mac'
bin_split = 'gotta_split_mac'
elif _platform == "win32":
bin_shi7en = 'ninja_shi7.exe'
bin_split = 'gotta_split_s.exe'
else:
print('Undefined OS\n')
raise SystemExit()

old_shi7en_bin = 'https://github.com/knights-lab/shi7en/releases/download/0.0.1/' + bin_shi7en
new_shi7en_bin = 'shi7en_trimmer'
old_split_bin = 'https://github.com/knights-lab/shi7en/releases/download/0.0.1/' + bin_split
new_split_bin = 'gotta_split'
download_txt_url(new_shi7en_bin, old_shi7en_bin)
download_txt_url(new_split_bin, old_split_bin)
os.chmod(new_shi7en_bin, 0o755)
os.chmod(new_split_bin, 0o755)

#TODO: maybe add $PATH

0 comments on commit 14c10aa

Please sign in to comment.