以下のコードを実行した後、
import os, shutil, glob, sys
source_dir = sys.argv[1]
list = ['file1', 'fil2']
for seek in list:
if seek == 'file1':
dest_dir = '/root/my_dir'
elif seek == 'file2':
dest_dir = '/root/my_dir'
paths = [(z, os.path.join(dest_dir, os.path.split(z)[1]))
for z in glob.glob(os.path.join(source_dir, seek))]
for p in paths:
if os.path.isfile(p[1]):
new_path = p[1] + '.bak'
print ('File "{0}" already exists;
moving to "{1}"'.format(p[1], new_path))
shutil.move(p[1], new_path)
shutil.copy2(p[0], p[1])
次の例外が生成されます。
File "./config1.py", line 22, in <module>
shutil.copy2(p[0], p[1])
File "/usr/local/lib/python3.0/shutil.py", line 99, in copy2
copyfile(src, dst)
File "/usr/local/lib/python3.0/shutil.py", line 54, in copyfile
copyfileobj(fsrc, fdst)
File "/usr/local/lib/python3.0/shutil.py", line 30, in copyfileobj
fdst.write(buf)
File "/usr/local/lib/python3.0/io.py", line 1055, in write
self._flush_unlocked()
File "/usr/local/lib/python3.0/io.py", line 1082, in _flush_unlocked
n = self.raw.write(self._write_buf)
IOError: [Errno 28] No space left on device