Enhanced yumcmd module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is code attached for four new methods for yumcmd module.


Thanks


#
#copyright 2008
# varinder singh <varin312@xxxxxxxxx>
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import yum
import func_module
from yum import Errors 


# XXX Use internal yum callback or write a useful one.
class DummyCallback(object):

    def event(self, state, data=None):
        pass


class Yum(func_module.FuncModule):

    # Update these if need be.
    version = "0.0.1"
    api_version = "0.0.1"
    description = "yum module for yumcmd install"



    def install(self, pkg=None):
	import yum
	ayum = yum.YumBase()
	ayum.doGenericSetup()
	ayum.doRepoSetup()
	try:
		ayum.doLock()
	        if pkg != None:
 	                tx_result = ayum.install(pattern=pkg)
			ayum.buildTransaction()
			ayum.processTransaction(callback=DummyCallback())
			tx_result = tx_result + ['Package Installed']	
 	        else:
 	                tx_result = ['Please Enter a Package Name to install']
	
	except Errors.InstallError, ex:
		tx_result = [str(ex)]
		
	finally:
 	        ayum.closeRpmDB()
 	        ayum.doUnlock()
 	return map(str, tx_result)


	

    def remove(self, pkg=None):
	import yum
	ayum = yum.YumBase()
	ayum.doGenericSetup()
	ayum.doRepoSetup()
	try:
		ayum.doLock()
                if pkg != None:
                        tx_result = ayum.remove(pattern=pkg)
			ayum.buildTransaction()
			ayum.processTransaction(callback=DummyCallback())
			tx_result = tx_result + ['Package removed']
                else:
                        tx_result = ['Please Enter a Package Name to remove']
        
	except Errors.InstallError, ex:
                tx_result = [str(ex)]

	finally:
                ayum.closeRpmDB()
                ayum.doUnlock()
        return map(str, tx_result)


    def groupinstall(self, grp=None):
        import yum
        ayum = yum.YumBase()
        ayum.doGenericSetup()
        ayum.doRepoSetup()
        try:
                ayum.doLock()
                if grp != None:
			if grp[0]!='@':
				grp = '@'+grp
                        tx_result = ayum._at_groupinstall(pattern=grp)
                        ayum.buildTransaction()
                        ayum.processTransaction(callback=DummyCallback())
                else:
                        tx_result = ['Please Enter a Group Name to install']

        except Errors.InstallError, ex:
                tx_result = [str(ex)]

        finally:
                ayum.closeRpmDB()
                ayum.doUnlock()
        return map(str, tx_result)

    def groupremove(self, grp=None):
        import yum
        ayum = yum.YumBase()
        ayum.doGenericSetup()
        ayum.doRepoSetup()
        try:
                ayum.doLock()
                if grp != None:
                        if grp[0]!='@':
                                grp = '@'+grp
                        tx_result = ayum._at_groupremove(pattern=grp)
                        ayum.buildTransaction()
                        ayum.processTransaction(callback=DummyCallback())
                else:
                        tx_result = ['Please Enter a Group Name to remove']

        except Errors.InstallError, ex:
                tx_result = [str(ex)]

        finally:
                ayum.closeRpmDB()
                ayum.doUnlock()
        return map(str, tx_result)
	
begin:vcard
fn:Varinder Singh 
n:;Varinder Singh 
email;internet:varin312@xxxxxxxxx
note;quoted-printable:vsjhand.learn.senecac.on.ca=0D=0A=
	varin312@xxxxxxxxx=0D=0A=
	varinderjhand.wordpress.com
version:2.1
end:vcard

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux