C++
#include <arc/Logger.h>
#include <arc/URL.h>
#include <arc/UserConfig.h>
#include <arc/data/DataHandle.h>
#include <arc/data/DataMover.h>
int main(int argc, char** argv) {
if (argc != 3) {
logger.msg(
Arc::ERROR,
"Usage: copy source destination");
return 1;
}
logger.msg(
Arc::ERROR,
"Copy failed: %s", std::string(result));
return 1;
}
return 0;
}
Python
import sys
import arc
import atexit
@atexit.register
def wait_exit():
arc.ThreadInitializer().waitExit()
def usage():
sys.stdout.write(' Usage: copy_file.py source destination\n')
if len(sys.argv) != 3:
usage()
sys.exit(1)
root_logger = arc.Logger_getRootLogger()
stream = arc.LogStream(sys.stdout)
root_logger.addDestination(stream)
root_logger.setThreshold(arc.ERROR)
cfg = arc.UserConfig()
source = arc.datapoint_from_url(sys.argv[1], cfg)
if source is None:
root_logger.msg(arc.ERROR, "Can't handle source "+sys.argv[1])
sys.exit(1)
destination = arc.datapoint_from_url(sys.argv[2], cfg)
if destination is None:
root_logger.msg(arc.ERROR, "Can't handle destination "+sys.argv[2])
sys.exit(1)
mover = arc.DataMover()
mover.verbose(True)
mover.retry(False)
status = mover.Transfer(source, destination, arc.FileCache(), arc.URLMap())
sys.stdout.write("%s\n"%str(status))