Skip to content

Commit

Permalink
delete: delete_log_screen()
Browse files Browse the repository at this point in the history
(cherry picked from commit 30209d7)
  • Loading branch information
yimelia committed Dec 28, 2020
1 parent 7802bde commit a2b6287
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions airtest/core/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,33 +172,3 @@ def import_device_cls(platform):

def delay_after_operation():
time.sleep(ST.OPDELAY)


def delete_log_screen(gt_time=float('-inf'), lt_time=float('inf')):
"""
Delete screenshots in the log directory(ST.LOG_DIR), delete all by default
Args:
gt_time: delete pictures with creation time greater than gt_time
lt_time: delete pictures with creation time less than lt_time
Examples:
>>> delete_log_screen() # delete all screenshots
>>> # delete screen.ctime < current time
>>> delete_log_screen(lt_time=time.time())
>>> # delete screen.ctime > timestamp
>>> delete_log_screen(gt_time=1604132541)
Returns:
None
"""
for f in os.listdir(ST.LOG_DIR):
if f.endswith(".jpg"):
f_path = os.path.join(ST.LOG_DIR, f)
ctime = os.path.getctime(f_path)
if gt_time <= ctime <= lt_time:
try:
os.remove(f_path)
except OSError:
pass

0 comments on commit a2b6287

Please sign in to comment.