def user_exists(p_user): user_data = util.getoutput ("cat /etc/passwd | egrep '^%s:' ; true" % p_user) if user_data: u = user_data.split(":") return dict(name=u[0],uid=u[2],gid=u[3],home=u[5],shell=u[6]) else: return None return(0)
def Install(self, localAddress="", remoteAddress=""): self.SetRemoteAddress(remoteAddress) self.WriteRequirement(self._packName, localAddress) # string: localAddress # where you want to put the remote package into, # for example: Analysis, Utility logging.info("workarea {}".format(self._workarea)) logging.info("The remote repository is {}".format(self._remoteAddress)) target = os.path.join(self._workarea, localAddress, self._packName) if os.path.exists(target): logging.info("the local package is exist!") output = getoutput("cd {}; git pull".format(target)) output = getoutput("cd {}; git remote -v".format(target)) print("target = {}".format(target)) try: remoteAddress = output.split("\n")[1].split()[1] except Exception as e: print(e) if remoteAddress.strip() != self._remoteAddress: while True and not self._force: c = raw_input( "The current remote Address is {} \n".format( remoteAddress) + "but the input is {}\n".format(self._remoteAddress) + "Do you want overwrite it? y/n:") # print(c) if c == "y": # print("yes \n") getoutput('cd {} ; /bin/rm -rf *'.format(target)) output = getoutput("git clone {} {}".format( self._remoteAddress, target)) print(output) break if c == "n": break if self._force: getoutput('cd {} ; /bin/rm -rf *'.format(target)) output = getoutput("git clone {} {}".format( self._remoteAddress, target)) else: logging.info("makedirs {}".format(target)) os.makedirs(target) output = getoutput("git clone {} {}".format( self._remoteAddress, target)) logging.debug(output)
def get_pgdg_base(p_ver, p_isJSON): basedir = None ver = p_ver svcname = None datadir = None port = None logdir = None to_devnull = " >/dev/null 2>&1" ####### (1) PGHOME ############################## if util.get_os() in YUM_LIST: basedir = "/usr/pgsql-" + ver else: basedir = "/usr/lib/postgresql/" + ver pgbin = basedir + "/bin/postgres" if not os.path.isfile(pgbin): print(" PGHOME could not be located at " + pgbin) return ("1111111") ###### (2) Service Control File ################# if util.get_os() in APT_LIST: svcname = "postgresql" else: svcname = "postgresql-" + ver if util.is_systemd(): sysdir = util.get_systemd_dir() svcfile = sysdir + "/" + svcname + ".service" else: sysdir = "/etc/init.d" svcfile = sysdir + "/" + svcname if not os.path.isfile(svcfile): print("ERROR: ServiceFile not found (" + svcfile + ")") return ("2222222") ###### (3) DATADIR ############################### if util.get_os() in YUM_LIST: datadir = "/var/lib/pgsql/" + ver + "/data" else: datadir = "/var/lib/postgresql/" + ver + "/main" cmd = "sudo ls " + datadir rc = os.system(cmd + to_devnull) if rc != 0: print("ERROR: DataDir not found (" + datadir + ")") return ("3333333") ##### LOOK FOR PORT #################### pidfile = datadir + "/postmaster.pid" cmd = "sudo ls " + pidfile rc = os.system(cmd + to_devnull) if rc == 0: cmd = "sudo cat " + pidfile + " | sed -n '4p'" port = util.getoutput(cmd) else: port = "1" ##### LOOK FOR LOGDIR ################## if util.get_os() in APT_LIST: logdir = "/var/log/postgresql" else: logdir = datadir + "/pg_log" cmd = "sudo ls " + logdir rc = os.system(cmd + to_devnull) if rc != 0: logdir = "" return ([basedir, ver, svcname, svcfile, datadir, port, logdir])
def list_packages(p_repo, p_SHOWDUPS, p_isJSON, p_isEXTRA): if not is_repo(p_repo, p_isJSON): util.exit_message(p_repo + " is not a valid REPO.", 1, p_isJSON) [repo_type, name, url, package, key, pkg_filter] = get_repo(p_repo, p_isJSON) if not is_installed(p_repo): util.exit_message(p_repo + " is not registered.", 1, p_isJSON) options = "" if p_SHOWDUPS: options = "--showduplicates" if util.get_os() in APT_LIST: return list_apt_packages(p_repo, p_isJSON) os = util.get_os() if os == "el6": cmd = "yum list all | grep " + p_repo else: cmd = "yum repo-pkgs " + p_repo + " list " + options cmd = cmd + " | awk '" ## filter package list unless asked to show --extra or --test kount = 0 if not p_isEXTRA: for p in pkg_filter: kount = kount + 1 ps = "/" + p.replace('.', '\.') + "/" if kount > 1: cmd = cmd + " || " + ps else: cmd = cmd + ps cmd = "sudo " + cmd + " { print }' | awk '!/debug/ && !/docs/ { print }'" outp = util.getoutput(cmd) my_logger.info("\n$ " + cmd + "\n\n" + str(outp)) repoList = [] for line in outp.splitlines(): data = line.split() if len(data) != 3: continue repoDict = {} p1 = data[0].find('.') pkg_nm = data[0][0:p1] p2 = data[1].find('.rhel') if p2 > 0: pkg_ver = data[1][0:p2] else: pkg_ver = data[1] status = "" if data[2].startswith("@"): status = "Installed" repoDict['component'] = pkg_nm repoDict['version'] = pkg_ver repoDict['status'] = status if pkg_nm > "": repoList.append(repoDict) keys = ['component', 'version', 'status'] headers = ['Component', 'Version', 'Status'] if p_isJSON: print(json.dumps(repoList, sort_keys=True, indent=2)) else: print(api.format_data_to_table(repoList, keys, headers)) return (0)
def info(p_json, p_home, p_repo, print_flag=True): import os p_user = util.get_user() p_is_admin = util.is_admin() pip_ver = get_pip_ver() this_os = "" this_uname = str(platform.system()) host_ip = util.get_host_ip() wmic_path = os.getenv("SYSTEMROOT", "") + os.sep + "System32" + os.sep + "wbem" + os.sep + "wmic" if this_uname == "Windows": import psutil host_display = os.getenv('LOGONSERVER','') + '\\' + os.getenv('COMPUTERNAME') system_cpu_cores = os.getenv('NUMBER_OF_PROCESSORS','1') os_arch = os.getenv('PROCESSOR_ARCHITECTURE', '') cpu_model = check_output_wmic([wmic_path, "cpu", "get", "name"]) ## system_memory_in_gb ###################################### m = psutil.virtual_memory().total mem_bytes = int(m) system_memory_in_kbytes = mem_bytes / 1024.0 system_memory_in_gb = str(mem_bytes / (1024.0**3)) else: os_arch = util.getoutput("uname -m") host_display = util.get_host_short() ## Check the OS & Resources ######################################## plat = util.get_os() os_major_ver = "" if this_uname == "Darwin": mem_mb = util.get_mem_mb() system_memory_in_kbytes = mem_mb * 1024 system_memory_in_gb = mem_mb / 1024.0 system_cpu_cores = util.get_cpu_cores() cpu_model=util.getoutput("/usr/sbin/sysctl -n machdep.cpu.brand_string") prod_name = util.getoutput("sw_vers -productName") prod_version = util.getoutput("sw_vers -productVersion") this_os = prod_name + " " + prod_version elif this_uname == "Linux": mem_mb = util.get_mem_mb() system_memory_in_kbytes = mem_mb * 1024 system_memory_in_gb = mem_mb / 1024.0 system_cpu_cores = util.get_cpu_cores() cpu_model=util.getoutput("grep 'model name' /proc/cpuinfo | head -1 | cut -d':' -f2") os_major_ver = util.getoutput("cat /etc/os-release | grep VERSION_ID | cut -d= -f2 | tr -d '\"'") if cpu_model == "": cpu_model="ARM" if os.path.exists("/etc/redhat-release"): this_os = util.getoutput("cat /etc/redhat-release") elif os.path.exists("/etc/system-release"): this_os = util.getoutput("cat /etc/system-release") elif os.path.exists("/etc/lsb-release"): this_os = util.getoutput("cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | cut -d= -f2 | tr -d '\"'") elif os.path.exists("/etc/os-release"): this_os = util.getoutput("cat /etc/os-release | grep PRETTY_NAME | cut -d= -f2 | tr -d '\"'") elif this_uname == "Windows": caption = check_output_wmic([wmic_path, "os", "get", "caption"]) svcpack = check_output_wmic([wmic_path, "os", "get", "servicepackmajorversion"]) if svcpack == "0": this_os = caption else: this_os = caption + ", SP " + svcpack round_mem = util.pretty_rounder(float(system_memory_in_gb), 1) mem = str(round_mem) + " GB" cores = str(system_cpu_cores) cpu = cpu_model.strip() cpu = cpu.replace("(R)", "") cpu = cpu.replace("(TM)", "") cpu = cpu.replace(" CPU ", " ") os = this_os.replace(" release ", " ") os = os.replace(" (Final)", "") arch = os_arch.replace("x86_64", "AMD") arch = arch.replace("AMD64", "AMD") ver = util.get_version() [last_update_utc, last_update_local, unique_id] = util.read_hosts('localhost') if last_update_local: last_upd_dt = datetime.strptime(last_update_local, "%Y-%m-%d %H:%M:%S") time_diff = int(util.timedelta_total_seconds(datetime.now() - last_upd_dt)) last_update_readable = util.get_readable_time_diff(str(time_diff), precision=2) versions_sql = util.get_versions_sql() perl_ver = util.get_perl_ver() [java_major_ver, java_ver] = util.get_java_ver() os_pkg_mgr = util.get_pkg_mgr() jvm_location = util.get_jvm_location() if p_json: infoJsonArray = [] infoJson = {} infoJson['version'] = ver infoJson['home'] = p_home infoJson['user'] = p_user infoJson['host'] = host_display infoJson['host_short'] = util.get_host_short() infoJson['host_long'] = util.get_host() infoJson['host_ip'] = util.get_host_ip() infoJson['os'] = unicode(str(os),sys.getdefaultencoding(),errors='ignore').strip() infoJson['os_pkg_mgr'] = os_pkg_mgr infoJson['os_major_ver'] = os_major_ver infoJson['platform'] = unicode(str(plat),sys.getdefaultencoding(),errors='ignore').strip() infoJson['arch'] = arch infoJson['mem'] = round_mem infoJson['cores'] = system_cpu_cores infoJson['cpu'] = cpu infoJson['last_update_utc'] = last_update_utc if last_update_local: infoJson['last_update_readable'] = last_update_readable infoJson['unique_id'] = unique_id infoJson['repo'] = p_repo infoJson['versions_sql'] = versions_sql infoJson['system_memory_in_kb'] = system_memory_in_kbytes infoJson['python_ver'] = python_ver infoJson['python_exe'] = python_exe if pip_ver != 'None': infoJson['pip_ver'] = pip_ver infoJson['perl_ver'] = perl_ver infoJson['java_ver'] = java_ver infoJson['java_major_ver'] = java_major_ver infoJson['jvm_location'] = jvm_location infoJsonArray.append(infoJson) if print_flag: print(json.dumps(infoJson)) return else: return infoJson if p_is_admin: admin_display = " (Admin)" else: admin_display = "" langs = "Python v" + python_ver if perl_ver > "": langs = langs + " | Perl v" + perl_ver if java_ver > "": langs = langs + " | Java v" + java_ver util.validate_distutils_click(False) print(style_start + ("#" * 70) + style_end) print(style_start + "# IO: " + style_end + "v" + ver + " " + p_home) print(style_start + "# User & Host: " + style_end + p_user + admin_display + " " + host_display) print(style_start + "# Operating System: " + style_end + os.rstrip() + " - " + str(plat)) print(style_start + "# Machine: " + style_end + mem + ", " + cores + " vCPU, " + cpu) print(style_start + "# Programming Langs: " + style_end + langs) default_repo = "https://openrds-download.s3.amazonaws.com/REPO" if p_repo != default_repo: print(style_start + "# Repo URL: " + style_end + p_repo) if versions_sql == "versions.sql": pass else: print(style_start + "# Versions SQL: " + style_end + versions_sql) if not last_update_local: last_update_local="None" print(style_start + "# Last Update: " + style_end + str(last_update_local)) print(style_start + ("#" * 70) + style_end)
def info(p_json, p_home, p_repo, print_flag=True): import os p_user = util.get_user() p_is_admin = util.is_admin() this_os = "" this_uname = str(platform.system()) host_ip = util.get_host_ip() wmic_path = os.getenv( "SYSTEMROOT", "") + os.sep + "System32" + os.sep + "wbem" + os.sep + "wmic" if this_uname == "Windows": import psutil host_display = os.getenv('LOGONSERVER', '') + '\\' + os.getenv('COMPUTERNAME') system_cpu_cores = os.getenv('NUMBER_OF_PROCESSORS', '1') os_arch = os.getenv('PROCESSOR_ARCHITECTURE', '') cpu_model = subprocess.check_output([wmic_path, "cpu", "get", "name"]).strip().split("\n")[1] ## system_memory_in_gb ###################################### m = psutil.virtual_memory().total mem_bytes = int(m) system_memory_in_kbytes = mem_bytes / 1024.0 system_memory_in_gb = mem_bytes / (1024.0**3) else: os_arch = util.getoutput("uname -m") HOST = util.get_host_short() host_display = "{0} {1}".format(HOST, host_ip) ## Check the OS & Resources ######################################## plat = util.get_os() if this_uname == "Darwin": system_memory_in_bytes = int( util.getoutput("/usr/sbin/sysctl hw.memsize | awk '{print $2}'")) system_memory_in_kbytes = system_memory_in_bytes / 1024 system_memory_in_gb = system_memory_in_bytes / 1024 / 1024 / 1024 system_cpu_cores = int( util.getoutput( "/usr/sbin/sysctl hw.physicalcpu | awk '{print $2}'")) cpu_model = util.getoutput( "/usr/sbin/sysctl -n machdep.cpu.brand_string") prod_name = util.getoutput("sw_vers -productName") prod_version = util.getoutput("sw_vers -productVersion") this_os = prod_name + " " + prod_version elif this_uname == "Linux": system_memory_in_kbytes = int( util.getoutput("cat /proc/meminfo | awk '/MemTotal/ {print $2}'")) system_memory_in_gb = system_memory_in_kbytes / 1024.0 / 1024.0 system_cpu_cores = int( util.getoutput( "egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo")) cpu_model = util.getoutput( "grep 'model name' /proc/cpuinfo | head -1 | cut -d':' -f2") if os.path.exists("/etc/redhat-release"): this_os = util.getoutput("cat /etc/redhat-release") elif os.path.exists("/etc/system-release"): this_os = util.getoutput("cat /etc/system-release") elif os.path.exists("/etc/lsb-release"): this_os = util.getoutput( "cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | cut -d= -f2 | tr -d '\"'" ) elif this_uname == "Windows": caption_result = subprocess.check_output( [wmic_path, "os", "get", "caption"]) try: caption = str(caption_result).strip().split("\n")[1] except UnicodeDecodeError as e: caption = unicode(caption_result, sys.getdefaultencoding(), errors='ignore').strip().split("\n")[1] svcpack_result = subprocess.check_output( [wmic_path, "os", "get", "servicepackmajorversion"]) try: svcpack = str(svcpack_result).strip().split("\n")[1] except UnicodeDecodeError as e: svcpack = unicode(svcpack_result, sys.getdefaultencoding(), errors='ignore').strip().split("\n")[1] if svcpack == "0": this_os = caption else: this_os = caption + ", SP " + svcpack round_mem = util.pretty_rounder(system_memory_in_gb, 1) mem = str(round_mem) + " GB" cores = str(system_cpu_cores) + " x" cpu = cpu_model.strip() cpu = cpu.replace("(R)", "") cpu = cpu.replace("(TM)", "") cpu = cpu.replace(" CPU ", " ") os = this_os.replace(" release ", " ") os = os.replace(" (Final)", "") arch = os_arch.replace("x86_64", "x64") arch = arch.replace("AMD64", "x64") ver = util.get_pgc_version() [ interval, last_update_utc, next_update_utc, last_update_local, next_update_local, unique_id ] = util.read_hosts('localhost') if last_update_local: last_upd_dt = datetime.strptime(last_update_local, "%Y-%m-%d %H:%M:%S") time_diff = int( util.timedelta_total_seconds(datetime.now() - last_upd_dt)) last_update_readable = util.get_readable_time_diff(str(time_diff), precision=2) versions_sql = util.get_versions_sql() if p_json: infoJsonArray = [] infoJson = {} infoJson['version'] = ver infoJson['home'] = p_home infoJson['user'] = p_user infoJson['host'] = host_display infoJson['host_short'] = util.get_host_short() infoJson['host_long'] = util.get_host() infoJson['host_ip'] = util.get_host_ip() infoJson['os'] = unicode(str(os), sys.getdefaultencoding(), errors='ignore').strip() infoJson['platform'] = unicode(str(plat), sys.getdefaultencoding(), errors='ignore').strip() infoJson['arch'] = arch infoJson['mem'] = round_mem infoJson['cores'] = system_cpu_cores infoJson['cpu'] = cpu infoJson['interval'] = interval infoJson['last_update_utc'] = last_update_utc if last_update_local: infoJson['last_update_readable'] = last_update_readable infoJson['next_update_utc'] = next_update_utc infoJson['unique_id'] = unique_id infoJson['repo'] = p_repo infoJson['versions_sql'] = versions_sql infoJson['system_memory_in_kb'] = system_memory_in_kbytes infoJson['python_ver'] = python_ver infoJson['python_exe'] = python_exe if pip_ver != 'None': infoJson['pip_ver'] = pip_ver infoJsonArray.append(infoJson) if print_flag: print(json.dumps(infoJsonArray, sort_keys=True, indent=2)) return else: return infoJson if p_is_admin: admin_display = " (Admin)" else: admin_display = "" print(style_start + ("#" * 70) + style_end) print(style_start + "# PGC: " + style_end + "v" + ver + " " + p_home) print(style_start + "# User & Host: " + style_end + p_user + admin_display + " " + host_display) print(style_start + "# Platform: " + style_end + plat + " | " + os.rstrip()) if pip_ver != "None": print(style_start + "# Python: " + style_end + "pip v" + pip_ver + \ " | v" + python_ver + " | " + python_exe) else: print(style_start + "# Python: " + style_end + "v" + python_ver + " | " + python_exe) print(style_start + "# Hardware: " + style_end + mem + ", " + cores + " " + cpu) default_repo = "https://s3.amazonaws.com/pgcentral" if p_repo != default_repo: print(style_start + "# Repo URL: " + style_end + p_repo) if versions_sql == "versions.sql": pass else: print(style_start + "# Versions SQL: " + style_end + versions_sql) if not last_update_local: last_update_local = "None" print(style_start + "# Last Update: " + style_end + str(last_update_local)) if interval: print(style_start + "# Update Interval: " + style_end + str(interval)) print(style_start + "# Next Update : " + style_end + str(next_update_local)) print(style_start + ("#" * 70) + style_end)
def get_list(p_isOLD, p_isExtensions, p_isJSON, p_isTEST, p_showLATEST, p_comp=None, p_relnotes=None, p_return=False): # r_sup_plat = util.like_pf("r.sup_plat") r_sup_plat = "1 = 1" if p_isOLD: exclude_comp = "" else: exclude_comp = " AND v.component NOT IN (SELECT component FROM components)" parent_comp_condition = "" installed_category_conditions = " AND p.category > 0 " available_category_conditions = " AND p.is_extension = 0" ext_component = "" if p_isExtensions: installed_category_conditions = " AND p.is_extension = 1" available_category_conditions = " AND p.is_extension = 1" if p_comp != "all": ext_component = " AND parent = '" + p_comp + "' " installed = \ "SELECT p.category, g.description as category_desc, g.short_desc as short_cat_desc, \n" + \ " c.component, c.version, c.port, c.status, r.stage, \n" + \ " coalesce((select is_current from versions where c.component = component AND c.version = version),0), \n" + \ " c.datadir, p.is_extension, \n" + \ " coalesce((select parent from versions where c.component = component and c.version = version),'') as parent, \n" + \ " coalesce((select release_date from versions where c.component = component and c.version = version),'20200101'), \n" + \ " c.install_dt, r.disp_name, \n" + \ " coalesce((select release_date from versions where c.component = component and is_current = 1),'20200101'), \n" + \ " r.is_available, r.available_ver \n" + \ " FROM components c, releases r, projects p, categories g \n" + \ " WHERE c.component = r.component AND r.project = p.project \n" + \ " AND p.category = g.category \n" + \ " AND " + r_sup_plat + installed_category_conditions + ext_component available = \ "SELECT c.category, c.description, c.short_desc as short_cat_desc, v.component, v.version, 0, 'NotInstalled', \n" + \ " r.stage, v.is_current, '', p.is_extension, v.parent as parent, v.release_date, '', \n" + \ " r.disp_name, \n" + \ " coalesce((select release_date from versions where v.component = component and is_current = 1),'20200101'), \n" + \ " r.is_available, r.available_ver \n" + \ " FROM versions v, releases r, projects p, categories c \n" + \ " WHERE v.component = r.component AND r.project = p.project \n" + \ " AND p.category = c.category AND v.is_current = 1 \n" + \ " AND " + util.like_pf("v.platform") + " \n" + \ " AND " + r_sup_plat + exclude_comp + available_category_conditions + ext_component extensions = \ "SELECT c.category, c.description, c.short_desc as short_cat_desc, v.component, v.version, 0, 'NotInstalled', \n" + \ " r.stage, v.is_current, '', p.is_extension, v.parent as parent, v.release_date, '', \n" + \ " r.disp_name, \n" + \ " coalesce((select release_date from versions where v.component = component and is_current = 1),'20200101'), \n" + \ " r.is_available, r.available_ver \n" + \ " FROM versions v, releases r, projects p, categories c \n" + \ " WHERE v.component = r.component AND r.project = p.project \n" + \ " AND p.is_extension = 1 AND p.category = c.category \n" + \ " AND " + util.like_pf("v.platform") + " \n" + \ " AND v.parent in (select component from components) AND " + r_sup_plat + exclude_comp if p_isExtensions: sql = installed + "\n UNION \n" + available + "\n ORDER BY 1, 3, 4, 6" else: sql = installed + "\n UNION \n" + available + "\n UNION \n" + extensions + "\n ORDER BY 1, 3, 4, 6" try: c = con.cursor() c.execute(sql) data = c.fetchall() headers = [ 'Category', 'Component', 'Version', 'ReleaseDt', 'Stage', 'Status', 'Updates' ] keys = [ 'short_cat_desc', 'component', 'version', 'release_date', 'stage', 'status', 'current_version' ] jsonList = [] kount = 0 previous_version = None previous_comp = None for row in data: compDict = {} kount = kount + 1 category = str(row[0]) category_desc = str(row[1]) short_cat_desc = str(row[2]) comp = str(row[3]) version = str(row[4]) port = str(row[5]) if previous_comp and previous_version: if previous_comp == comp and previous_version == version: continue previous_version = version previous_comp = comp if str(row[6]) == "Enabled": status = "Installed" else: status = str(row[6]) if status == "NotInstalled" and p_isJSON == False: status = "" is_available = str(row[16]) if ((status == "") and (is_available > "")): rc = os.system(is_available + " > /dev/null 2>&1") if rc == 0: status = "Available" stage = str(row[7]) if stage in ("soon", "bring-own", "included"): continue is_current = str(row[8]) if is_current == "0" and status in ("", "NotInstalled"): if not p_isOLD: continue current_version = get_current_version(comp) is_update_available = 0 cv = Version.coerce(current_version) iv = Version.coerce(version) if cv > iv: is_update_available = 1 if is_update_available == 0: updates = 0 current_version = "" else: updates = 1 if (port == "0") or (port == "1"): port = "" datadir = row[9] if row[9] is None: datadir = "" else: datadir = str(row[9]).strip() is_extension = row[10] parent = row[11] disp_name = row[14] release_desc = '' release_date = '1970-01-01' curr_rel_date = '1970-01-01' curr_rel_dt = str(row[15]) rel_dt = str(row[12]) if len(rel_dt) == 8: release_date = rel_dt[0:4] + "-" + rel_dt[4:6] + "-" + rel_dt[ 6:8] curr_rel_date = curr_rel_dt[0:4] + "-" + curr_rel_dt[ 4:6] + "-" + curr_rel_dt[6:8] compDict['is_new'] = 0 try: rd = datetime.datetime.strptime(release_date, '%Y-%m-%d') today_date = datetime.datetime.today() date_diff = (today_date - rd).days if date_diff <= 30: compDict['is_new'] = 1 if p_showLATEST and date_diff > 30: continue except Exception as e: pass if util.is_postgres(comp): if port > "" and status == "Installed" and datadir == "": status = "NotInitialized" port = "" ins_date = str(row[13]) install_date = "" compDict['is_updated'] = 0 if ins_date: install_date = ins_date[0:4] + "-" + ins_date[ 5:7] + "-" + ins_date[8:10] try: insDate = datetime.datetime.strptime( install_date, '%Y-%m-%d') today_date = datetime.datetime.today() date_diff = (today_date - insDate).days if date_diff <= 30: compDict['is_updated'] = 1 except Exception as e: pass available_ver = str(row[17]) if ((status == "Available") and (available_ver > "")): current_version = version version = util.getoutput(available_ver) if current_version == version: current_version = "" if p_relnotes and p_isJSON: rel_version = version if current_version != "": rel_version = current_version rel_notes = str(util.get_relnotes(comp, rel_version)) markdown_text = unicode(rel_notes, sys.getdefaultencoding(), errors='ignore').strip() html_text = mistune.markdown(markdown_text) compDict['rel_notes'] = html_text compDict['category'] = category compDict['category_desc'] = category_desc compDict['short_cat_desc'] = short_cat_desc compDict['component'] = comp compDict['version'] = version compDict['is_extension'] = is_extension compDict['disp_name'] = disp_name compDict['release_desc'] = release_desc compDict['port'] = port compDict['release_date'] = release_date compDict['install_date'] = install_date compDict['curr_release_date'] = curr_rel_date compDict['status'] = status compDict['stage'] = stage compDict['updates'] = updates compDict['is_current'] = is_current compDict['current_version'] = current_version compDict['parent'] = parent jsonList.append(compDict) if p_return: return jsonList if p_isJSON: print(json.dumps(jsonList, sort_keys=True, indent=2)) else: if len(jsonList) >= 1: if p_showLATEST: print("New components released in the last 30 days.") print(api.format_data_to_table(jsonList, keys, headers)) except Exception as e: fatal_error(e, sql, "meta.get_list()") sys.exit(0)