#!/usr/bin/env python
import atexit
+import contextlib
import errno
import shutil
import subprocess
return directory
+@contextlib.contextmanager
+def scoped_cwd(path):
+ cwd = os.getcwd()
+ os.chdir(path)
+ try:
+ yield
+ finally:
+ os.chdir(cwd)
+
+
def download(text, url, path):
with open(path, 'w') as local_file:
web_file = urllib2.urlopen(url)
import glob
import os
import subprocess
+import sys
import tempfile
+from lib.util import *
+
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def main():
try:
ensure_s3put()
+ if not dist_newer_than_head():
+ create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
+ subprocess.check_call([sys.executable, create_dist])
upload()
except AssertionError as e:
return e.message
assert 'multipart' in output, 'Error: Please install boto and filechunkio'
+def dist_newer_than_head():
+ with scoped_cwd(SOURCE_ROOT):
+ try:
+ head_time = subprocess.check_output(['git', 'log', '--pretty=format:%at',
+ '-n', '1']).strip()
+ dist_time = os.path.getmtime(os.path.join(SOURCE_ROOT, 'atom-shell.zip'))
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
+ return False
+
+ return dist_time > int(head_time)
+
+
def upload():
os.chdir(SOURCE_ROOT)
bucket, access_key, secret_key = s3_config()