示例#1
0
文件: query.py 项目: simon-r/aurpy
    def test_installed_package(self , pkg_name ):
        """
        Search an installed package.
        :param pkg_name: The name of the package
        :rtype: a list containing [ name , version ] 
        """
        
        pl = tools.clean_pkg_name( pkg_name )
        
        cmd = "pacman -Q %s"%pl
        
        #print( cmd )
        #print( pl )
        
        try:
            out = check_output( cmd.split() , stderr=open( os.devnull ) ).decode().strip().split()
        except :
            return None
        
#         if len( pl ) > 1 :
#             v = ver.version( pl )
#             vi = ver.version( out[1] )
#             
#             if vi < v :
#                 return None
        
        return out
示例#2
0
文件: query.py 项目: simon-r/aurpy
    def test_repo_package( self , pkg_name ):
        """
        Search the package in the synchronized repository:
        :param pkg_name: The name of the package
        :rtype: return a list containing [ name , repository , version ]. If the package do non exists it return None 
        """
        
        pl = tools.clean_pkg_name ( pkg_name )
        
        cmd = "pacman -Si %s"%pl
        try:
            out = check_output( cmd.split() , stderr=open( os.devnull ) ).decode().strip().splitlines()
        except :
            return None
        
#         if len( pl ) > 1 :
#             v = ver.version( pl[1] )
#             vi = ver.version( out[2].split()[2] )
#             
#             if vi < v :
#                 return None     
        
        out = [ out[1].split()[2] , out[0].split()[2] , out[2].split()[2] ]
        
        return out
示例#3
0
文件: query.py 项目: simon-r/aurpy
 def test_aur_package( self , pkg_name ):
     """
     Test if a package exists in AUR
     :param pkg_name: The name of the package
     :rtype: True if it exists of False
     """
     
     pl = tools.clean_pkg_name( pkg_name )
     
     config = cfg.aurpy_config()
     
     opener = urllib.request.FancyURLopener({})
     
     url = config.get_pkg_url( glob.AUR , pl )
     f = opener.open( url )
     
     try :
         aur_html = f.read().decode()
         
         if re.search ( "404\s+\-\s+Page\s+Not\s+Found" , aur_html ) :
             return False 
         
     except :
         return False
     
     return True
     
             
     
示例#4
0
文件: package.py 项目: simon-r/aurpy
 def build_depends_rec(self):
     aur_l   = self.get_depends_aur() 
     aur_mkl = self.get_depends_aur( "makedepends" )
     
     repo_l   = self.get_depends_repo()
     repo_mkl = self.get_depends_repo("makedepends")
     
     print( aur_l + aur_mkl + repo_l + repo_mkl )
     if len(aur_l) + len(aur_mkl) == 0 :
         return False
     
     self._depends = defaultdict()
     
     for dd in ( aur_l + aur_mkl + repo_l + repo_mkl ) :
         d = tools.clean_pkg_name( dd )
         print(d)
         pkg = package()
         pkg.name = d 
         
         if tools.own_package( d , aur_l + aur_mkl ) :
             pkg.origin = glob.AUR
         else :
             pkg.origin = glob.PACKAGES
             
         f = pkg.read_repo_data()
         
         if not f :
             raise package_not_found( " The package named: %s do not exists ! "%d )
              
         ######################################
         ######################################
         pkg.read_pkgbuild_data() 
         pkg.test_dependecies()
         
         if tools.own_package( d , aur_mkl ) :
             pkg.reason = glob.MAKE_DEPENDS
         else :
             pkg.reason = glob.DEPENDS
         
         print( "ssssssssssssssssssssssssssssssssssssss" )
         #pkg.read_pkgbuild_data() 
         pkg.build_depends_rec()
         
         self._depends[ pkg.name ] = pkg
       
     return True