User:Ikrustok: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
fi | fi | ||
</source> | |||
<source lang="python"> | |||
#!/usr/bin/python | |||
#Autor: Ivar Krustok A22, ikrustok@itcollege.ee | |||
#Version: 1 | |||
#Skript paki installi kontrolliks,kui puudub pakub sul installida | |||
import os, subprocess | |||
from apt import Cache | |||
tark = raw_input("Tere palun sisesta programmi nimi, mida soovite kontrollida: ") | |||
devnull = open(os.devnull,"w") | |||
retval = subprocess.call(["dpkg","-s",tark],stdout=devnull,stderr=subprocess.STDOUT) | |||
devnull.close() | |||
if retval != 0: | |||
print "Package", tark, "ei ole installitud." | |||
else: | |||
print "Package", tark, "on juba installitud", exit(1) | |||
kys = raw_input("Kas soovite seda programmi installida? [jah/ei]") | |||
if kys == "jah": | |||
kys2 = raw_input("Olete te kindlad? [jah/ei]") | |||
else: | |||
print "Head aega siis", exit(1) | |||
if kys2 == "jah": | |||
cache = Cache() | |||
package = cache[tark] | |||
package.mark_install(), cache.commit() | |||
else: | |||
print "Olgu, head aega siis!" | |||
</source> | </source> |
Revision as of 19:36, 23 May 2011
Quest lahendus 11 - Skript paki installi kontrolliks
#!/bin/bash
#Autor: Ivar Krustok A22, ikrustok@itcollege.ee
#Version: 2
#Skript paki installi kontrolliks
PAKK=$1
TARK=`/usr/bin/apt-cache policy $PAKK | grep Installed | awk '{print $2}'`
echo $TARK
if [ "$TARK" == "(none)" ]; then
echo "0"
else
echo "1"
fi
#!/usr/bin/python
#Autor: Ivar Krustok A22, ikrustok@itcollege.ee
#Version: 1
#Skript paki installi kontrolliks,kui puudub pakub sul installida
import os, subprocess
from apt import Cache
tark = raw_input("Tere palun sisesta programmi nimi, mida soovite kontrollida: ")
devnull = open(os.devnull,"w")
retval = subprocess.call(["dpkg","-s",tark],stdout=devnull,stderr=subprocess.STDOUT)
devnull.close()
if retval != 0:
print "Package", tark, "ei ole installitud."
else:
print "Package", tark, "on juba installitud", exit(1)
kys = raw_input("Kas soovite seda programmi installida? [jah/ei]")
if kys == "jah":
kys2 = raw_input("Olete te kindlad? [jah/ei]")
else:
print "Head aega siis", exit(1)
if kys2 == "jah":
cache = Cache()
package = cache[tark]
package.mark_install(), cache.commit()
else:
print "Olgu, head aega siis!"