mps.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/python3
  2. #
  3. # Copyright (c) 2017 milisarge MPS İşlev (Api) Sınıfı
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to
  7. # deal in the Software without restriction, including without limitation the
  8. # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. # sell copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. # IN THE SOFTWARE.
  22. import os
  23. import subprocess
  24. class MpsIslev():
  25. aktif_komut=[]
  26. def kos(self,komut="@aktif_komut",donus=False):
  27. cikti=""
  28. if komut == "@aktif_komut":
  29. #os.system(self.aktif_komut)
  30. cikti = subprocess.check_output(self.aktif_komut)
  31. else:
  32. #os.system(komut)
  33. cikti = subprocess.check_output(komut)
  34. #print (self.tr_cevir(cikti))
  35. if donus:
  36. return self.tr_cevir(cikti)
  37. def surum(self):
  38. self.aktif_komut=["mps","-v"]
  39. return self.aktif_komut
  40. def talimat(self,paket):
  41. self.aktif_komut=["mps","talimat",paket]
  42. komut="%s %s %s" % ("mps","talimat",paket)
  43. return komut
  44. def gruplar(self,cikti="--json"):
  45. self.aktif_komut=["mps","gruplar",cikti]
  46. komut="%s %s %s" % ("mps","gruplar",cikti)
  47. return komut
  48. def grup_paketler(self,grup,cikti="--json"):
  49. self.aktif_komut=["mps","paketler",grup,cikti]
  50. komut="%s %s %s %s" % ("mps","paketler",grup,cikti)
  51. return komut
  52. def bilgi(self,paket,renk="yok"):
  53. if renk=="yok":
  54. renkdurum="--html"
  55. self.aktif_komut=["mps","-b",paket,renkdurum]
  56. return self.aktif_komut
  57. def yukselt(self):
  58. self.aktif_komut=["mps","yukselt"]
  59. komut="%s %s" % ("mps","yukselt")
  60. return komut
  61. def tr_cevir(self,cikti):
  62. return cikti.decode('utf-8')
  63. # test
  64. '''
  65. mps=MpsIslev()
  66. print(mps.talimat("atool"))
  67. mps.kos()
  68. '''