From 4a190b91e659597e4ea39ea1e1db1a68b3e37a06 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 08:35:36 +0100 Subject: [PATCH 01/11] Update splitFile.py only set attrib on non unix machines --- tools/splitFile.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index 6aaab66..47c12f2 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -42,8 +42,9 @@ def splitQuick(filepath): shutil.rmtree(dir) os.makedirs(dir) - if os.path.exists(dir): - subprocess.call(['attrib', '+a', dir]) + if (os.name != "posix"): + if os.path.exists(dir): + subprocess.call(['attrib', '+a', dir]) # Move input file to directory and rename it to first part filename = os.path.basename(filepath) @@ -108,8 +109,9 @@ def splitCopy(filepath): shutil.rmtree(dir) os.makedirs(dir) - if os.path.exists(dir): - subprocess.call(['attrib', '+a', dir]) + if (os.name != "posix"): + if os.path.exists(dir): + subprocess.call(['attrib', '+a', dir]) remainingSize = fileSize From cfd68d10f6c32ecd7f23622eb6cb23a1414052d1 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 10:48:17 +0100 Subject: [PATCH 02/11] Update splitFile.py set archive attrib only on windows os --- tools/splitFile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index 47c12f2..f4280c1 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -42,7 +42,7 @@ def splitQuick(filepath): shutil.rmtree(dir) os.makedirs(dir) - if (os.name != "posix"): + if (os.name == "nt"): if os.path.exists(dir): subprocess.call(['attrib', '+a', dir]) @@ -109,7 +109,7 @@ def splitCopy(filepath): shutil.rmtree(dir) os.makedirs(dir) - if (os.name != "posix"): + if (os.name == "nt"): if os.path.exists(dir): subprocess.call(['attrib', '+a', dir]) From d5d08d3b4f5aaafede62ed7fbb16872ed4a4dba7 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:22:23 +0100 Subject: [PATCH 03/11] Update splitFile.py using mattrib as alternative for attrib in windows installation of mtools is required, so the script checks if the command is available prior execution --- tools/splitFile.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/splitFile.py b/tools/splitFile.py index f4280c1..df1591e 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -15,6 +15,10 @@ splitSize = 0xFFFF0000 # 4,294,901,760 bytes chunkSize = 0x8000 # 32,768 bytes +def checkCommand(name): + from shutil import which + return which(name) is not None + from os.path import splitext def splitext_(path): if len(path.split('.')) > 2: @@ -45,6 +49,19 @@ def splitQuick(filepath): if (os.name == "nt"): if os.path.exists(dir): subprocess.call(['attrib', '+a', dir]) + elif (os.name == "posix"): + if checkCommand("mattrib"): + if os.path.exists(dir): + subprocess.call(['mattrib', '+a', dir]) + else: + print('Could not set archivbit!') + print('mtools are not installed.') + print('You need to set it manually for the folder! Or install mtools and restart the job.') + + else: + print('Could not set archivbit! Environment unknown!') + print('You need to set it manually for the folder!') + # Move input file to directory and rename it to first part filename = os.path.basename(filepath) @@ -112,6 +129,19 @@ def splitCopy(filepath): if (os.name == "nt"): if os.path.exists(dir): subprocess.call(['attrib', '+a', dir]) + elif (os.name == "posix"): + if checkCommand("mattrib"): + if os.path.exists(dir): + subprocess.call(['mattrib', '+a', dir]) + else: + print('Could not set archivbit!') + print('mtools are not installed.') + print('You need to set it manually for the folder! Or install mtools and restart the job.') + + else: + print('Could not set archivbit! Environment unknown!') + print('You need to set it manually for the folder!') + remainingSize = fileSize From 6a9b09e6c90491af688a09313f45d1c82cdd5cba Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:29:03 +0100 Subject: [PATCH 04/11] Update splitFile.py --- tools/splitFile.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index df1591e..8b079fd 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -50,18 +50,17 @@ def splitQuick(filepath): if os.path.exists(dir): subprocess.call(['attrib', '+a', dir]) elif (os.name == "posix"): - if checkCommand("mattrib"): + if checkCommand("mattrib"): if os.path.exists(dir): subprocess.call(['mattrib', '+a', dir]) - else: + else: print('Could not set archivbit!') - print('mtools are not installed.') + print('mtools are not installed.') print('You need to set it manually for the folder! Or install mtools and restart the job.') - else: - print('Could not set archivbit! Environment unknown!') - print('You need to set it manually for the folder!') - + print('Could not set archivbit! Environment unknown!') + print('You need to set it manually for the folder!') + # Move input file to directory and rename it to first part filename = os.path.basename(filepath) @@ -130,18 +129,17 @@ def splitCopy(filepath): if os.path.exists(dir): subprocess.call(['attrib', '+a', dir]) elif (os.name == "posix"): - if checkCommand("mattrib"): + if checkCommand("mattrib"): if os.path.exists(dir): subprocess.call(['mattrib', '+a', dir]) - else: + else: print('Could not set archivbit!') - print('mtools are not installed.') + print('mtools are not installed.') print('You need to set it manually for the folder! Or install mtools and restart the job.') - else: - print('Could not set archivbit! Environment unknown!') - print('You need to set it manually for the folder!') - + print('Could not set archivbit! Environment unknown!') + print('You need to set it manually for the folder!') + remainingSize = fileSize From 2f122e0f2f70a7a91d11485f807a11a4a563f4e0 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:43:11 +0100 Subject: [PATCH 05/11] Update splitFile.py --- tools/splitFile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index 8b079fd..396b474 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -52,7 +52,7 @@ def splitQuick(filepath): elif (os.name == "posix"): if checkCommand("mattrib"): if os.path.exists(dir): - subprocess.call(['mattrib', '+a', dir]) + subprocess.call(['mattrib', '+a', dir, '>/dev/null', '2>&1', '||', 'echo', '"Could not set archivbit! Probably not a Windows Filesystem!"']) else: print('Could not set archivbit!') print('mtools are not installed.') @@ -131,7 +131,7 @@ def splitCopy(filepath): elif (os.name == "posix"): if checkCommand("mattrib"): if os.path.exists(dir): - subprocess.call(['mattrib', '+a', dir]) + subprocess.call(['mattrib', '+a', dir, '>/dev/null', '2>&1', '||', 'echo', '"Could not set archivbit! Probably not a Windows Filesystem!"']) else: print('Could not set archivbit!') print('mtools are not installed.') From 097400db3dad2cff750f01d97958861740da4f49 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:47:46 +0100 Subject: [PATCH 06/11] Update splitFile.py --- tools/splitFile.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index 396b474..1507062 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -52,7 +52,12 @@ def splitQuick(filepath): elif (os.name == "posix"): if checkCommand("mattrib"): if os.path.exists(dir): - subprocess.call(['mattrib', '+a', dir, '>/dev/null', '2>&1', '||', 'echo', '"Could not set archivbit! Probably not a Windows Filesystem!"']) + try: + subprocess.check_call(['mattrib', '+a', dir]) + except subprocess.CalledProcessError: + print('Could not set archivbit! Probably not a Windows Filesystem!') + except OSError: + pass # executable not found else: print('Could not set archivbit!') print('mtools are not installed.') @@ -131,7 +136,12 @@ def splitCopy(filepath): elif (os.name == "posix"): if checkCommand("mattrib"): if os.path.exists(dir): - subprocess.call(['mattrib', '+a', dir, '>/dev/null', '2>&1', '||', 'echo', '"Could not set archivbit! Probably not a Windows Filesystem!"']) + try: + subprocess.check_call(['mattrib', '+a', dir]) + except subprocess.CalledProcessError: + print('Could not set archivbit! Probably not a Windows Filesystem!') + except OSError: + pass # executable not found else: print('Could not set archivbit!') print('mtools are not installed.') From 8eb25c1e565dd2b04493ce6a9c002d53adbc6676 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:49:13 +0100 Subject: [PATCH 07/11] Update splitFile.py --- tools/splitFile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index 1507062..d5ea098 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -53,7 +53,7 @@ def splitQuick(filepath): if checkCommand("mattrib"): if os.path.exists(dir): try: - subprocess.check_call(['mattrib', '+a', dir]) + subprocess.check_call(['mattrib', '+a', dir], stdout=FNULL, stderr=subprocess.STDOUT) except subprocess.CalledProcessError: print('Could not set archivbit! Probably not a Windows Filesystem!') except OSError: @@ -132,7 +132,7 @@ def splitCopy(filepath): if (os.name == "nt"): if os.path.exists(dir): - subprocess.call(['attrib', '+a', dir]) + subprocess.call(['attrib', '+a', dir], stdout=FNULL, stderr=subprocess.STDOUT) elif (os.name == "posix"): if checkCommand("mattrib"): if os.path.exists(dir): From 3bb827f4bae1c1e8a575838a3bd3a96dc2d58917 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:49:56 +0100 Subject: [PATCH 08/11] Update splitFile.py --- tools/splitFile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index d5ea098..221b7bf 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -53,7 +53,7 @@ def splitQuick(filepath): if checkCommand("mattrib"): if os.path.exists(dir): try: - subprocess.check_call(['mattrib', '+a', dir], stdout=FNULL, stderr=subprocess.STDOUT) + subprocess.check_call(['mattrib', '+a', dir], stdout=FNULL, stderr=FNULL) except subprocess.CalledProcessError: print('Could not set archivbit! Probably not a Windows Filesystem!') except OSError: @@ -132,7 +132,7 @@ def splitCopy(filepath): if (os.name == "nt"): if os.path.exists(dir): - subprocess.call(['attrib', '+a', dir], stdout=FNULL, stderr=subprocess.STDOUT) + subprocess.call(['attrib', '+a', dir], stdout=FNULL, stderr=FNULL) elif (os.name == "posix"): if checkCommand("mattrib"): if os.path.exists(dir): From ae189904f87b5f3e1865aa1704059538057e1829 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:51:22 +0100 Subject: [PATCH 09/11] Update splitFile.py --- tools/splitFile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/splitFile.py b/tools/splitFile.py index 221b7bf..11eda46 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -15,6 +15,8 @@ splitSize = 0xFFFF0000 # 4,294,901,760 bytes chunkSize = 0x8000 # 32,768 bytes +FNULL = open(os.devnull, 'w') + def checkCommand(name): from shutil import which return which(name) is not None From 7fb9a44d0fd9ef39e5f0d89c866ff1a42c5ea00a Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:52:37 +0100 Subject: [PATCH 10/11] Update splitFile.py --- tools/splitFile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index 11eda46..4915035 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -55,7 +55,7 @@ def splitQuick(filepath): if checkCommand("mattrib"): if os.path.exists(dir): try: - subprocess.check_call(['mattrib', '+a', dir], stdout=FNULL, stderr=FNULL) + subprocess.check_call(['attrib', '+a', dir], stdin=FNULL, stdout=FNULL, stderr=FNULL) except subprocess.CalledProcessError: print('Could not set archivbit! Probably not a Windows Filesystem!') except OSError: @@ -134,7 +134,7 @@ def splitCopy(filepath): if (os.name == "nt"): if os.path.exists(dir): - subprocess.call(['attrib', '+a', dir], stdout=FNULL, stderr=FNULL) + subprocess.check_call(['attrib', '+a', dir], stdin=FNULL, stdout=FNULL, stderr=FNULL) elif (os.name == "posix"): if checkCommand("mattrib"): if os.path.exists(dir): From 632344729aabfcf0d4f377cc24c7bacf2f3791c5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 22 Feb 2019 11:55:55 +0100 Subject: [PATCH 11/11] Update splitFile.py --- tools/splitFile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/splitFile.py b/tools/splitFile.py index 4915035..7bce9a2 100644 --- a/tools/splitFile.py +++ b/tools/splitFile.py @@ -26,7 +26,7 @@ def splitext_(path): if len(path.split('.')) > 2: return path.split('.')[0],'.'.join(path.split('.')[-2:]) return splitext(path) - + def splitQuick(filepath): fileSize = os.path.getsize(filepath) info = shutil.disk_usage(os.path.dirname(os.path.abspath(filepath))) @@ -55,7 +55,7 @@ def splitQuick(filepath): if checkCommand("mattrib"): if os.path.exists(dir): try: - subprocess.check_call(['attrib', '+a', dir], stdin=FNULL, stdout=FNULL, stderr=FNULL) + subprocess.check_call(['mattrib', '+a', dir], stdin=FNULL, stdout=FNULL, stderr=FNULL) except subprocess.CalledProcessError: print('Could not set archivbit! Probably not a Windows Filesystem!') except OSError: @@ -134,12 +134,12 @@ def splitCopy(filepath): if (os.name == "nt"): if os.path.exists(dir): - subprocess.check_call(['attrib', '+a', dir], stdin=FNULL, stdout=FNULL, stderr=FNULL) + subprocess.check_call(['attrib', '+a', dir]) elif (os.name == "posix"): if checkCommand("mattrib"): if os.path.exists(dir): try: - subprocess.check_call(['mattrib', '+a', dir]) + subprocess.check_call(['mattrib', '+a', dir], stdin=FNULL, stdout=FNULL, stderr=FNULL) except subprocess.CalledProcessError: print('Could not set archivbit! Probably not a Windows Filesystem!') except OSError: