Created
November 2, 2012 15:34
Revisions
-
chrox revised this gist
Nov 29, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ def notification(filename): def delete_old_downloads(repo): for download in repo.get_downloads(): if datetime.now() - download.created_at > timedelta(days=30): download.delete() def create_download(repo, filepath): -
chrox revised this gist
Nov 11, 2012 . 2 changed files with 8 additions and 8 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,8 @@ def delete_old_downloads(repo): download.delete() def create_download(repo, filepath): t = datetime.now() - timedelta(days=1) date = t.strftime("%Y%m%d") filename = "kindlepdfviewer-nightly-" + date + ".zip" comments = "kindlepdfviewer nightly build on " + date filetype = "application/zip" This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,13 @@ #!/bin/sh echo "clone kindlepdfviewer into dev directory" cd ~/dev rm -rf kindlepdfviewer git clone git://github.com/hwhw/kindlepdfviewer.git cd kindlepdfviewer echo "compile and build customupdate" PATH="/opt/arm-2012.03/bin:$PATH" make fetchthirdparty make thirdparty kpdfview customupdate kpvzip=`find kindlepdfviewer*.zip |sort -r |head -1` ~/bin/github-upload.py $kpvzip -
chrox revised this gist
Nov 4, 2012 . 2 changed files with 7 additions and 4 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,10 +58,12 @@ def upload_file(response, filename): arg_list.extend(["-F", "Content-Type=%s" %response.mime_type]) arg_list.extend(["-F", "file=@%s" %filename]) arg_list.append(response.s3_url) arg_list.extend(["--retry","3","--max-time","300"]) arg_list.append("-v") os.environ["ALL_PROXY"] = PROXY return subprocess.call(arg_list) if __name__ == '__main__': github_instance = Github(USER_TOKEN) user = github_instance.get_user() @@ -92,4 +94,4 @@ def upload_file(response, filename): else: print("Upload file failed...%d" %exit_code) print("Try again.") time.sleep(5) This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,8 @@ git pull git reset --hard echo "compile and build customupdate" PATH="/opt/arm-2012.03/bin:$PATH" make fetchthirdparty make clean cleanthirdparty make thirdparty kpdfview customupdate kpvzip=`find kindlepdfviewer*.zip |sort -r |head -1` /home/XXXXXX/bin/github-upload.py $kpvzip -
chrox revised this gist
Nov 2, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/sh echo "change into kindlepdfviewer directory" cd /home/XXXXXX/dev/kindlepdfviewer echo "reset local tree to upstream" git pull git reset --hard @@ -10,4 +10,4 @@ PATH="/opt/arm-2012.03/bin:$PATH" make clean make kpdfview customupdate kpvzip=`find kindlepdfviewer*.zip |sort -r |head -1` /home/XXXXXX/bin/github-upload.py $kpvzip -
chrox revised this gist
Nov 2, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/sh echo "change into kindlepdfviewer directory" cd /home/user/dev/kindlepdfviewer echo "reset local tree to upstream" git pull git reset --hard @@ -10,4 +10,4 @@ PATH="/opt/arm-2012.03/bin:$PATH" make clean make kpdfview customupdate kpvzip=`find kindlepdfviewer*.zip |sort -r |head -1` /home/user/bin/github-upload.py $kpvzip -
chrox created this gist
Nov 2, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,95 @@ #!/usr/bin/python import os import sys import time from datetime import datetime,timedelta import subprocess from github import Github PROXY = "http://192.168.1.101:7071" USER_TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" REPO = "kindlepdfviewer" EMAIL = "XXXXXXXXXX@gmail.com" def notification(filename): SENDMAIL = "/usr/sbin/sendmail" p = os.popen("%s -t" % SENDMAIL, "w") p.write("To: " + EMAIL + "\n") p.write("Subject: kpv nightly build uploaded!\n") p.write(filename + " is uploaded.\n") sts = p.close() if sts != 0: print "Sendmail exit status", sts def delete_old_downloads(repo): for download in repo.get_downloads(): if datetime.now() - download.created_at > timedelta(days=7): download.delete() def create_download(repo, filepath): date = time.strftime('%Y%m%d', time.localtime()) filename = "kindlepdfviewer-nightly-" + date + ".zip" comments = "kindlepdfviewer nightly build on " + date filetype = "application/zip" filesize = os.path.getsize(filepath) print("filename: " + filename) print("comments: " + comments) print("filesize: " + str(filesize)) for download in repo.get_downloads(): if download.name == filename: print("delete previously uploaded file " + filename) download.delete() response = repo.create_download(filename, filesize, comments, filetype) print("created download at " + response.html_url) return response def upload_file(response, filename): arg_list = [] arg_list.append("curl") arg_list.extend(["-F", "key=%s" %response.path]) arg_list.extend(["-F", "acl=%s" %response.acl]) arg_list.extend(["-F", "success_action_status=201"]) arg_list.extend(["-F", "Filename=%s" %response.name]) arg_list.extend(["-F", "AWSAccessKeyId=%s" %response.accesskeyid]) arg_list.extend(["-F", "Policy=%s" %response.policy]) arg_list.extend(["-F", "Signature=%s" %response.signature]) arg_list.extend(["-F", "Content-Type=%s" %response.mime_type]) arg_list.extend(["-F", "file=@%s" %filename]) arg_list.append(response.s3_url) os.environ["ALL_PROXY"] = PROXY return subprocess.call(arg_list) if __name__ == '__main__': github_instance = Github(USER_TOKEN) user = github_instance.get_user() repo = user.get_repo(REPO) filename = sys.argv[1] created = False while(not created): try: delete_old_downloads(repo) response = create_download(repo, filename) created = True except Exception, e: print("Caught exception " + str(e)) uploaded = False while(not uploaded): try: exit_code = upload_file(response, filename) except Exception, e: print("Caught exception " + str(e)) continue else: if exit_code == 0: print("File uploaded successfully.") notification(filename) uploaded = True else: print("Upload file failed...%d" %exit_code) print("Try again.") time.sleep(5) This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ #!/bin/sh echo "change into kindlepdfviewer directory" cd /home/matrix/dev/kindlepdfviewer echo "reset local tree to upstream" git pull git reset --hard echo "compile and build customupdate" PATH="/opt/arm-2012.03/bin:$PATH" make clean make kpdfview customupdate kpvzip=`find kindlepdfviewer*.zip |sort -r |head -1` /home/matrix/bin/github-upload.py $kpvzip