File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed
src/DIRAC/FrameworkSystem/private Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Original file line number Diff line number Diff line change 1
- from __future__ import absolute_import
2
- from __future__ import division
3
- from __future__ import print_function
4
-
5
1
import os
6
2
import re
7
3
import time
8
4
import gzip
9
5
import queue
6
+ import shutil
10
7
import threading
11
8
from DIRAC import gLogger , S_OK , S_ERROR
12
9
from DIRAC .Core .Utilities .ThreadScheduler import gThreadScheduler
@@ -77,14 +74,9 @@ def __unlinkOldLog(self, filePath):
77
74
def __zipOldLog (self , filePath ):
78
75
try :
79
76
gLogger .info ("Compressing file %s" % filePath )
80
- fd = gzip .open ("%s.gz" % filePath , "w" )
81
- with open (filePath ) as fO :
82
- bS = 1048576 # 1MiB
83
- buf = fO .read (bS )
84
- while buf :
85
- fd .write (buf )
86
- buf = fO .read (bS )
87
- fd .close ()
77
+ with open (filePath , "rb" ) as f_in :
78
+ with gzip .open ("%s.gz" % filePath , "wb" ) as f_out :
79
+ shutil .copyfileobj (f_in , f_out )
88
80
except Exception :
89
81
gLogger .exception ("Can't compress old log file" , filePath )
90
82
return 1
You can’t perform that action at this time.
0 commit comments