def upload_archives(archives): for dir_rel_url, files in paths.group_by_target_url_dir(archives): ''' # Delete this next line and all but one of the examples below. raise Exception("No upload method specified: edit upload_archives() in 0repo-config.py") # Example 1 : simple copy to local web-server directory archives_local_dir = "/home/me/public_html/archives/" subprocess.check_call(["cp", "--"] + files + [join(archives_local_dir, dir_rel_url)]) # Example 2 : scp to remote server subprocess.check_call(["scp", "--"] + files + [join("me@myserver:/home/me/webapps/myrepo/archives/" + dir_rel_url)]) ''' # Example 3 : upload to SourceForge file release system user = '******'#'sf-user-name' project = 'freecad-convert'#'sf-project-name' dir_rel_url_parts = dir_rel_url.split("/") # project/files/version version = dir_rel_url_parts[len(dir_rel_url_parts) - 1] #path = '/home/frs/project/{p}/{pr}/{project}/{dir_rel_url}/'.format( path = '/home/frs/project/{project}/{version}/'.format( #p = project[0], #pr = project[:2], project = project, version = version ) cmd = ['rsync', '-avP', '--progress', '-e', 'ssh'] + files + \ [user + ',' + project + '@frs.sourceforge.net:' + path] print ' '.join(cmd) subprocess.check_call(cmd)
def testGrouping(self): a = archives.Archive('/tmp/a.tgz', 'a.tgz', 0) b = archives.Archive('/tmp/b.tgz', 'foo/sub/b.tgz', 0) c = archives.Archive('/tmp/c.tgz', 'foo/sub/c.tgz', 0) groups = {d: fs for d, fs in paths.group_by_target_url_dir([a, b, c])} self.assertEqual(['', 'foo/sub'], sorted(groups)) self.assertEqual(['/tmp/a.tgz'], sorted(groups[''])) self.assertEqual(['/tmp/b.tgz', '/tmp/c.tgz'], sorted(groups['foo/sub']))
def upload_archives(archives): print(archives) for dir_rel_url, files in paths.group_by_target_url_dir(archives): # Delete this next line and all but one of the examples below. # raise Exception("No upload method specified: edit upload_archives() in 0repo-config.py") # Example 1 : simple copy to local web-server directory archives_local_dir = "%s/archives" % FEED_UPLOAD_DIR subprocess.check_call(["cp", "--"] + files + [join(archives_local_dir, dir_rel_url)])
def upload_archives(archives): for dir_rel_url, files in paths.group_by_target_url_dir(archives): # Example 2 : scp to remote server # subprocess.check_call(["scp", "--"] + files + [join("me@myserver:/home/me/webapps/myrepo/archives/" + dir_rel_url)]) print(repr(dir_rel_url)) print(repr(files)) user = '******' path = '/home/eanderso/luwak.org/x/sims001/archives/' cmd = ['rsync', '-avP', '--progress', '-e', 'ssh','--delete-during'] + files + \ [user + '@blackboard.dreamhost.com:' + path] print(' '.join(cmd)) ##subprocess.call("env") rv = subprocess.check_call(cmd) print('rv={rv}'.format(rv=rv)) return