Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
import json
import os
import shutil
import sys
import threading

return_values = []

def copyfile(src, dst):
    try:
        os.makedirs(os.path.dirname(dst), 0o755)
    except Exception as ex:
        print(ex)

    try:
        shutil.copyfile(src, dst)
    except Exception as ex:
        print(ex)
        return_values.append(2)

if __name__ == "__main__":
    print(sys.argv)

    if len(sys.argv) != 2:
        print("Usage: pcopy <filestocopy>")
        sys.exit(1)

    path = sys.argv[1]
    if not os.path.exists(path) or not os.path.isfile(path):
        print("%s must be a file" % path)
        sys.exit(1)

    with open(path, "r") as f:
        x = json.load(f)

    threads = []
    for i in x:
        t = threading.Thread(target=copyfile, args=i)
        t.start()
        threads.append(t)

    for i in threads:
        i.join()

    if len(return_values):
        sys.exit(1)
    else:
        sys.exit(0)