-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmps.py
144 lines (135 loc) · 3.45 KB
/
mps.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# -*- coding: utf-8 -*-
import sqlite3 as sqlmak
import sys
import datetime
import os
import decimal
import time
import codecs
import random
import re
import sys
import urllib2, urllib
from random import randint
import datetime
from stdnum import ean
import ctypes
import codecs
import subprocess
import crypt
import yaml
import hashlib
from arge import *
import tempfile
arger=Arge()
class Mps:
def paket_sunucu(self):
ayarlar=self.mpsayarlar()
return ayarlar["sunucu"]
def paket_kur(self,paket):
rapor=""
raporgc = tempfile.mktemp()
komut="mps kur "+paket+" &> "+raporgc
arger.komutCalistir(komut)
with open(raporgc) as f:
icerik = f.readlines()
rapor+="<html>"
for veri in icerik:
if "cekiliyor" in veri:
veri1=veri.split("33m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "paket sunucuda yok" in veri:
veri1=veri.split("31m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "indiriliyor" in veri:
veri1=veri.split("34m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "paketi kuruldu" in veri:
veri1=veri.split("34m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "paketi kuruluyor" in veri:
veri1=veri.split("34m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
rapor+="</html>"
os.remove(raporgc)
return rapor
def paket_sil(self,paket):
rapor=""
raporgc = tempfile.mktemp()
komut="mps -sz "+paket+" &> "+raporgc
arger.komutCalistir(komut)
with open(raporgc) as f:
icerik = f.readlines()
rapor+="<html>"
for veri in icerik:
if "31m" in veri:
veri1=veri.split("31m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "32m" in veri:
veri1=veri.split("32m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "34m" in veri:
veri1=veri.split("34m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
rapor+="</html>"
os.remove(raporgc)
return rapor
def paket_guncelle(self,paket):
rapor=""
raporgc = tempfile.mktemp()
komut="mps -g "+paket+" &> "+raporgc
arger.komutCalistir(komut)
with open(raporgc) as f:
icerik = f.readlines()
rapor+="<html>"
for veri in icerik:
if "31m" in veri:
veri1=veri.split("31m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "32m" in veri:
veri1=veri.split("32m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "33m" in veri:
veri1=veri.split("33m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
if "34m" in veri:
veri1=veri.split("34m")[1]
veri2=veri1.split("[0;39m")[0]
rapor+=veri2+"<br>"
rapor+="</html>"
os.remove(raporgc)
return rapor
def paketvt_guncelle(self):
durum="olumsuz"
raporgc = tempfile.mktemp()
os.system("mps -G &> "+raporgc)
rapor=open(raporgc,"r").read()
if "güncelleniyor" in rapor:
durum="tamam"
return durum
def git_guncelle(self):
durum="olumsuz"
raporgc = tempfile.mktemp()
os.system("mps -GG &> "+raporgc)
rapor=open(raporgc,"r").read()
if "tamam." in rapor:
durum="tamam"
return durum
def mpsayarlar(self,dosya="/etc/mps.conf"):
ayarlar = {}
with open(dosya) as ayardos:
for satir in ayardos:
anahtar, deger = satir.partition("=")[::2]
ayarlar[anahtar.strip()] = deger.rstrip()
return ayarlar