Created
September 9, 2013 09:21
-
-
Save Superbil/6493367 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 characters
#!/user/bin/env python | |
import zipfile | |
import os.path | |
import time | |
from shutil import copyfile | |
def zipdir(path, zip): | |
relroot = os.path.abspath(os.path.join(path, "..")) | |
for root, dirs, files in os.walk(path): | |
for file in files: | |
arc_name = os.path.join(os.path.relpath(root, relroot), file) | |
zip.write(filename = os.path.join(root, file), | |
arcname = arc_name) | |
def main(): | |
project_name = "Project" | |
base_path = "~/Library/Developer/Xcode/DerivedData/Build/Products/Test-iphoneos/" | |
targets = ["Project.app", "Project.app.dSYM"] | |
beta_path = "Where to push" | |
zip_file_name = "%s_%s%s" % (project_name, time.strftime("%Y%m%d_%H%M"), ".zip") | |
zip_file_path = "%s%s" % (base_path, zip_file_name) | |
# check targets is exists | |
for target in targets: | |
target_path = "%s%s" % (base_path, target) | |
if not os.path.exists(target_path): | |
print "%s not exists" %(target_path) | |
exit(1) | |
# zip files | |
with zipfile.ZipFile(zip_file_path, 'w', zipfile.ZIP_DEFLATED) as zip: | |
for target in targets: | |
path = "%s%s" % (base_path, target) | |
if os.path.isdir(path): | |
zipdir(path, zip) | |
if os.path.isfile(path): | |
zip.write(path, arcname = target) | |
# copy to beta | |
if os.path.exists(zip_file_path): | |
if os.path.exists(beta_path): | |
copyfile(zip_file_path, os.path.join(beta_path, zip_file_name)) | |
else: | |
print "beta folder is not exists" | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment