atomicshop 2.11.47__py3-none-any.whl → 2.11.48__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of atomicshop might be problematic. Click here for more details.
- atomicshop/__init__.py +1 -1
- atomicshop/filesystem.py +59 -11
- {atomicshop-2.11.47.dist-info → atomicshop-2.11.48.dist-info}/METADATA +1 -1
- {atomicshop-2.11.47.dist-info → atomicshop-2.11.48.dist-info}/RECORD +7 -7
- {atomicshop-2.11.47.dist-info → atomicshop-2.11.48.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.11.47.dist-info → atomicshop-2.11.48.dist-info}/WHEEL +0 -0
- {atomicshop-2.11.47.dist-info → atomicshop-2.11.48.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
atomicshop/filesystem.py
CHANGED
|
@@ -7,6 +7,8 @@ import stat
|
|
|
7
7
|
import errno
|
|
8
8
|
from contextlib import contextmanager
|
|
9
9
|
|
|
10
|
+
import psutil
|
|
11
|
+
|
|
10
12
|
from .print_api import print_api, print_status_of_list
|
|
11
13
|
from .basics import strings, list_of_dicts
|
|
12
14
|
from .file_io import file_io
|
|
@@ -1180,6 +1182,29 @@ def create_dict_of_path(
|
|
|
1180
1182
|
current_level = existing_entry["included"]
|
|
1181
1183
|
|
|
1182
1184
|
|
|
1185
|
+
def list_open_files_in_directory(directory):
|
|
1186
|
+
"""
|
|
1187
|
+
The function lists all open files by any processes in the directory.
|
|
1188
|
+
:param directory:
|
|
1189
|
+
:return:
|
|
1190
|
+
"""
|
|
1191
|
+
open_files: list = []
|
|
1192
|
+
|
|
1193
|
+
# Iterate over all running processes
|
|
1194
|
+
for proc in psutil.process_iter(['pid', 'name']):
|
|
1195
|
+
try:
|
|
1196
|
+
# List open files for the process
|
|
1197
|
+
proc_open_files = proc.open_files()
|
|
1198
|
+
for file in proc_open_files:
|
|
1199
|
+
if file.path.startswith(directory):
|
|
1200
|
+
open_files.append((proc.info['pid'], proc.info['name'], file.path))
|
|
1201
|
+
except (psutil.AccessDenied, psutil.NoSuchProcess):
|
|
1202
|
+
# Ignore processes that can't be accessed
|
|
1203
|
+
continue
|
|
1204
|
+
|
|
1205
|
+
return open_files
|
|
1206
|
+
|
|
1207
|
+
|
|
1183
1208
|
def is_any_file_in_directory_locked(directory_path: str) -> bool:
|
|
1184
1209
|
"""
|
|
1185
1210
|
The function checks if any file in the directory is locked (if the file is currently being written to that directory
|
|
@@ -1190,10 +1215,24 @@ def is_any_file_in_directory_locked(directory_path: str) -> bool:
|
|
|
1190
1215
|
:return: boolean, if 'True', then at least one file in the directory is locked.
|
|
1191
1216
|
"""
|
|
1192
1217
|
|
|
1193
|
-
for filename in os.listdir(directory_path):
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1218
|
+
# for filename in os.listdir(directory_path):
|
|
1219
|
+
# file_path = os.path.join(directory_path, filename)
|
|
1220
|
+
# if os.path.isfile(file_path):
|
|
1221
|
+
# return is_file_locked(file_path)
|
|
1222
|
+
# return False
|
|
1223
|
+
|
|
1224
|
+
# Iterate over all running processes
|
|
1225
|
+
for proc in psutil.process_iter(['pid', 'name']):
|
|
1226
|
+
try:
|
|
1227
|
+
# List open files for the process
|
|
1228
|
+
proc_open_files = proc.open_files()
|
|
1229
|
+
for file in proc_open_files:
|
|
1230
|
+
if file.path.startswith(directory_path):
|
|
1231
|
+
return True
|
|
1232
|
+
except (psutil.AccessDenied, psutil.NoSuchProcess):
|
|
1233
|
+
# Ignore processes that can't be accessed
|
|
1234
|
+
continue
|
|
1235
|
+
|
|
1197
1236
|
return False
|
|
1198
1237
|
|
|
1199
1238
|
|
|
@@ -1221,11 +1260,20 @@ def is_file_locked(file_path: str) -> bool:
|
|
|
1221
1260
|
:return: boolean, if 'True', then the file is locked.
|
|
1222
1261
|
"""
|
|
1223
1262
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1263
|
+
# If the file doesn't exist, or it is not a file, it's not locked.
|
|
1264
|
+
if not os.path.isfile(file_path):
|
|
1265
|
+
return False
|
|
1266
|
+
|
|
1267
|
+
# Iterate over all running processes
|
|
1268
|
+
for proc in psutil.process_iter(['pid', 'name']):
|
|
1269
|
+
try:
|
|
1270
|
+
# List open files for the process
|
|
1271
|
+
proc_open_files = proc.open_files()
|
|
1272
|
+
for file in proc_open_files:
|
|
1273
|
+
if file.path == file_path:
|
|
1274
|
+
return True
|
|
1275
|
+
except (psutil.AccessDenied, psutil.NoSuchProcess):
|
|
1276
|
+
# Ignore processes that can't be accessed
|
|
1277
|
+
continue
|
|
1278
|
+
|
|
1231
1279
|
return False
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=cFT8R-KwR0UCeMnGtLPqN3BpDbAz4usM9rbu1PpVwTg,124
|
|
2
2
|
atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
|
|
3
3
|
atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
|
|
4
4
|
atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
|
|
@@ -14,7 +14,7 @@ atomicshop/dns.py,sha256=bNZOo5jVPzq7OT2qCPukXoK3zb1oOsyaelUwQEyK1SA,2500
|
|
|
14
14
|
atomicshop/domains.py,sha256=Rxu6JhhMqFZRcoFs69IoEd1PtYca0lMCG6F1AomP7z4,3197
|
|
15
15
|
atomicshop/emails.py,sha256=I0KyODQpIMEsNRi9YWSOL8EUPBiWyon3HRdIuSj3AEU,1410
|
|
16
16
|
atomicshop/file_types.py,sha256=-0jzQMRlmU1AP9DARjk-HJm1tVE22E6ngP2mRblyEjY,763
|
|
17
|
-
atomicshop/filesystem.py,sha256=
|
|
17
|
+
atomicshop/filesystem.py,sha256=tpuFGFo6sjsuTILY0K-NI4w3CsELoGOoFpAViSnGtzs,47658
|
|
18
18
|
atomicshop/functions.py,sha256=pK8hoCE9z61PtWCxQJsda7YAphrLH1wxU5x-1QJP-sY,499
|
|
19
19
|
atomicshop/hashing.py,sha256=Le8qGFyt3_wX-zGTeQShz7L2HL_b6nVv9PnawjglyHo,3474
|
|
20
20
|
atomicshop/http_parse.py,sha256=nrf2rZcprLqtW8HVrV7TCZ1iTBcWRRy-mXIlAOzcaJs,9703
|
|
@@ -244,8 +244,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
|
|
|
244
244
|
atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
|
|
245
245
|
atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
|
|
246
246
|
atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
|
|
247
|
-
atomicshop-2.11.
|
|
248
|
-
atomicshop-2.11.
|
|
249
|
-
atomicshop-2.11.
|
|
250
|
-
atomicshop-2.11.
|
|
251
|
-
atomicshop-2.11.
|
|
247
|
+
atomicshop-2.11.48.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
248
|
+
atomicshop-2.11.48.dist-info/METADATA,sha256=hrq4NMvVR15pdZZrP0cmhUp6Vy42wQxe0QOIkf-_vZ4,10448
|
|
249
|
+
atomicshop-2.11.48.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
250
|
+
atomicshop-2.11.48.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
251
|
+
atomicshop-2.11.48.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|