Package config_client :: Module rhncfgcli_list
[hide private]
[frames] | no frames]

Source Code for Module config_client.rhncfgcli_list

 1  # 
 2  # Copyright (c) 2008--2016 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU General Public License, 
 5  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 6  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 8  # along with this software; if not, see 
 9  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
10  # 
11  # Red Hat trademarks are not licensed under GPLv2. No permission is 
12  # granted to use or replicate Red Hat trademarks that are incorporated 
13  # in this software or its documentation. 
14  # 
15   
16  from config_common.rhn_log import log_debug, die 
17   
18  import handler_base 
19  import sys 
20   
21 -class Handler(handler_base.HandlerBase):
22 - def run(self):
23 log_debug(2) 24 r = self.repository 25 26 files = r.list_files() 27 28 if not files: 29 die(1, "No managed files.") 30 31 label = "Config Channel" 32 maxlen = max([len(s[0]) for s in files]) 33 maxlen = max(maxlen, len(label)) + 2 34 35 print("DoFoS %*s %s" % (maxlen, label, "File")) 36 arg_files = [] 37 if len(sys.argv) > 2: 38 arg_files = sys.argv[2:len(sys.argv)] 39 40 for file in files: 41 42 if len(arg_files) and not file[1] in arg_files: 43 continue 44 45 # checking to see if the filetype is in the 'file' entry, 46 # and if it is and that type is '1', it is a file 47 if (len(file) < 3) or file[2] == 1: 48 print("F %*s %s" % (maxlen, file[0], file[1])) 49 elif file[2] == 2 : 50 # the filetype is a directory 51 print("D %*s %s" % (maxlen, file[0], file[1])) 52 else: 53 print("S %*s %s" % (maxlen, file[0], file[1]))
54