-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
37 lines (32 loc) · 1.09 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Load-balanced file caching on local disks"""
from cmlogging import LogLevel
from client import ClientConfiguration, CmClient
__version__ = "$Rev: 821 $"
__author__ = "[email protected] (David Rybach)"
__copyright__ = "Copyright 2012, RWTH Aachen University"
def cacheFile(filename, verbose=True):
"""convenience function to cache a file to the local disk.
returns the path of the cached file.
"""
loglevel = LogLevel.level
if not verbose:
LogLevel.level = 0
config = ClientConfiguration()
config.loadDefault()
client = CmClient(config)
cachedFile, ok = client.fetch(filename)
LogLevel.set(loglevel)
return cachedFile
def copyFile(source, destination, verbose=True):
"""convenience function to copy a file from the local disk to a file server.
returns true if the file was copied.
"""
loglevel = LogLevel.level
if not verbose:
LogLevel.level = 0
config = ClientConfiguration()
config.loadDefault()
client = CmClient(config)
ok = client.copy(source, destination)
LogLevel.set(loglevel)
return ok