Created
February 6, 2013 10:31
-
-
Save level09/4721760 to your computer and use it in GitHub Desktop.
video fabfile
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
from fabric.api import put, run , local , env | |
from fabric.contrib.files import exists | |
from settings import VOD_HOST, VOD_PATH, PHP_COMMAND,MAG_HOST, MAG_PATH | |
from glob import glob | |
import os | |
def vod(): | |
env.hosts = [VOD_HOST] | |
def upload(path): | |
put(path,VOD_PATH) | |
def insert_to_cms(package_name): | |
run(PHP_COMMAND % package_name) | |
def mag(): | |
env.hosts = [MAG_HOST] | |
def mag_upload(path): | |
files = [] | |
targets = [] | |
target_dir_name = os.path.basename(path) | |
target_path = MAG_PATH + '/' + target_dir_name | |
for file in glob(path+'/*.f4v'): | |
files.append(file) | |
targets.append(str_fix(os.path.basename(file))) | |
for file in glob(path+'/*.jpg'): | |
files.append(file) | |
targets.append(str_fix(os.path.basename(file))) | |
#transfer files | |
#create target dir if not exists | |
if not exists(target_path): | |
run('mkdir '+ target_path) | |
try: | |
for i in range(len(files)): | |
put(files[i] , target_path + '/' + targets[i] ) | |
print 'copying xml file from %s :to: %s' %(path+'/'+'ucm.xml', target_path) | |
put(path+'/'+'ucm.xml',target_path) | |
except Exception, e: | |
print 'Error uploading to magnolia: %r' %e | |
def str_fix(str): | |
return str.replace(' ','-') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment