Debian Codegraph @

src/copy_files_verbose.py

raw
1 #!/usr/bin/env python3
2
3 # Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
4 #
5 # This file is part of DeVeDe-NG
6 #
7 # DeVeDe-NG is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 3
9 # as published by the Free Software Foundation.
10 #
11 # DeVeDe-NG is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>
18
19 import sys
20 import os
21
22 if len(sys.argv) != 3:
23 print("Usage: copy_files_verbose input_file output_file")
24 sys.exit(-1)
25
26 filesize = os.path.getsize(sys.argv[1])
27 done = 0.0
28 f1 = open(sys.argv[1], "rb")
29 f2 = open(sys.argv[2], "wb")
30
31 while (done < filesize):
32 data = f1.read(65536)
33 f2.write(data)
34 done += len(data)
35 print("Copied %.1f%%" % (100.0 * float(done) / float(filesize)))