-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbildirim.py
executable file
·64 lines (53 loc) · 1.54 KB
/
bildirim.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import time
import uuid
import os
import sys
import ayarlar as ayar
import subprocess
import pkgutil
if pkgutil.find_loader("gsocketpool") is None:
os.system("pip3 install gsocketpool")
import gsocketpool.pool
if pkgutil.find_loader("mprpc") is None:
os.system("pip3 install mprpc")
from mprpc import RPCPoolClient
#from gi.repository import Notify
#Notify.init("App Name")
#Notify.Notification.new("Hi").show()
kimlik=str(uuid.UUID(int=uuid.getnode()))
kimlik=kimlik.split("-")[4]
kimlik=ayar.kimlik+"#"+kimlik
MESAJ_DIZINI="./mesajlar/"
BILDIRIM_SURE=10000
os.makedirs(MESAJ_DIZINI, exist_ok=True)
def ilet(baslik,message,sure=3000):
subprocess.Popen(['notify-send',"--expire-time="+str(sure),baslik, message])
return
client_pool = gsocketpool.pool.Pool(RPCPoolClient, dict(host=ayar.sunucu, port=ayar.port))
def mliste_al():
liste=[]
for mesajd in os.listdir(MESAJ_DIZINI):
dosya=os.path.basename(mesajd)
liste.append(dosya)
return liste
while True:
time.sleep(2)
try:
with client_pool.connection() as client:
print ("sunucu bağlanıyor...")
#canlılık kaydı gönder
mesaj=client.call('nabiz_at',kimlik)
mesaj=str(mesaj)
print(mesaj)
ymliste=client.call('mesaj_al',kimlik,mliste_al())
if ymliste:
for ym in ymliste:
open(MESAJ_DIZINI+ym[0],"w").write(ym[1])
ilet("ileti",ym[1],BILDIRIM_SURE)
print ("ymliste >>> ",ymliste)
#ilet("ileti",mesaj)
print ("sunucu bağlandı...")
except:
print("bağlantıda sorun var",ayar.sunucu,ayar.port)