revert a4c2ead and add a PermissionError check instead
This commit is contained in:
@@ -49,15 +49,19 @@ RESULTS_SUBFOLDERS = ['belts', 'inputshaper', 'vibrations']
|
|||||||
|
|
||||||
|
|
||||||
def is_file_open(filepath):
|
def is_file_open(filepath):
|
||||||
try:
|
for proc in os.listdir('/proc'):
|
||||||
with open(filepath, 'a') as file:
|
if proc.isdigit():
|
||||||
fcntl.flock(file.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
for fd in glob.glob(f'/proc/{proc}/fd/*'):
|
||||||
# File is not in use (and can be used safely)
|
try:
|
||||||
fcntl.flock(file.fileno(), fcntl.LOCK_UN)
|
if os.path.samefile(fd, filepath):
|
||||||
return False
|
return True
|
||||||
except IOError:
|
except FileNotFoundError:
|
||||||
# File is still in use (and should not be touched for now)
|
# Klipper has already released the CSV file
|
||||||
return True
|
pass
|
||||||
|
except PermissionError:
|
||||||
|
# Unable to check for this particular process due to permissions
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_belts_graph():
|
def get_belts_graph():
|
||||||
|
|||||||
Reference in New Issue
Block a user