-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
53 lines (38 loc) · 1.41 KB
/
utils.py
File metadata and controls
53 lines (38 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os, ctypes, urllib, datetime
def getDisplayMetrics(index):
#Возвращаем разрешение экрана
user32 = ctypes.windll.user32
user32.SetProcessDPIAware()
width = user32.GetSystemMetrics(0)
height = user32.GetSystemMetrics(1)
return [width, height][index]
def makeDir():
# создаем директорию для хранения изображений
try:
os.mkdir('images')
except OSError:
return
def getDir():
# возвращаем директорию для хранения изображений
makeDir()
return os.getcwd() + '\\images'
def checkInternetActive():
#Проверяет подключен ли интернет
try:
urllib.request.urlopen("http://google.com")
return True
except IOError:
return False
def checkDateCreateImg():
# Проверяет обновлялись ли фотографии текущим днем
try:
path = getDir()
file_list = os.listdir(path)
for i in file_list:
imgUrl = os.path.join(path, i)
dateCreate = datetime.datetime.fromtimestamp(os.path.getmtime(imgUrl))
deadline = datetime.datetime.now()
if (dateCreate.year == deadline.year and dateCreate.month == deadline.month and dateCreate.day == deadline.day): return False
else: return True
except:
return True