RPM vesion string.
549945
def version(self):
        """"""
        stdout = Cmd.sh_e_out('{0} --version'.format(self.rpm_path))
        rpm_version = stdout.split()[2]
        return rpm_version
11536
String
rrToString()
{
	StringBuffer sb = new StringBuffer();
	sb.append(next);
	if (!types.empty()) {
		sb.append(' ');
		sb.append(types.toString());
	}
	return sb.toString();
}
457713
def get_rpm_version(package_name):
    """"""
    version_result = subprocess.run(["rpm", "-q", package_name],
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
    if version_result.returncode == 0:
        return version_result.stdout.decode().rstrip()
    else:
        return None
1023883
private static String bitsToString(long megabits) {
        int unit = 1000;
        if (megabits < unit) {
            return megabits + " mb";
        }
        int exp = (int) (Math.log(megabits) / Math.log(unit));
        return new DecimalFormat("#.##").format(megabits / Math.pow(unit, exp)) + "GTPE".charAt(exp - 1) + "b";
    }
1076911
def run_string(self, string, metadata=None):
        """"""
        token = Token(string, metadata)
        return [str(tkn) for tkn in self.run([token])]
524221
def _msToString(self, ms):
        """"""
        hr, ms = divmod(ms, 3600000)
        mins, ms = divmod(ms, 60000)
        secs, mill = divmod(ms, 1000)
        return "%ihr %imin %isecs %ims" % (hr, mins, secs, mill)
761900
def create_srpm(dist='el7'):
    
    if not RPM_AVAILABLE:
        raise RpmModuleNotAvailable()
    path = os.getcwd()
    try:
        specfile = spec_fn()
        spec = Spec(specfile)
    except Exception:
        return

    rpmdefines = ["--define 'dist .{}'".format(dist),
                  "--define '_sourcedir {}'".format(path),
                  "--define '_srcrpmdir {}'".format(path)]
    rpm.addMacro('_sourcedir', '.{}'.format(dist))
    # FIXME: needs to be fixed in Spec
    rpm.addMacro('dist', '.{}'.format(dist))
    module_name = spec.get_tag('Name', True)
    version = spec.get_tag('Version', True)
    release = spec.get_tag('Release', True)
    srpm = os.path.join(path,
                        "{}-{}-{}.src.rpm".format(module_name,
                                                  version,
                                                  release))

    # See if we need to build the srpm
    if os.path.exists(srpm):
        log.warn('Srpm found, rewriting it.')

    cmd = ['rpmbuild']
    cmd.extend(rpmdefines)

    cmd.extend(['--nodeps', '-bs', specfile])
    output = subprocess.check_output(' '.join(cmd), shell=True)
    log.warn(output)
    srpm = output.split()[1]
    return srpm
948936
def _str_sid(self):
    ''
    sub_auths = "-".join([str(sub) for sub in self.sub_authorities])
    return f'S-{self.revision_number}-{self.authority}-{sub_auths}'
163215
def dt2str(dt, flagSeconds=True):
    """"""
    if isinstance(dt, str):
        return dt
    return dt.strftime(_FMTS if flagSeconds else _FMT)
1046922
def rpm_info(rpm_path):
    
    ts = rpm.TransactionSet()
    ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
    rpm_info = {}

    rpm_fd = open(rpm_path, 'rb')
    pkg = ts.hdrFromFdno(rpm_fd)
    rpm_info['name'] = pkg['name']
    rpm_info['version'] = pkg['version']
    rpm_info['release'] = pkg['release']
    rpm_info['epoch'] = 0
    rpm_info['arch'] = pkg['arch']
    rpm_info['nvrea'] = tuple((rpm_info['name'], rpm_info['version'], rpm_info['release'], rpm_info['epoch'], rpm_info['arch']))
    rpm_info['cksum'] = hashlib.md5(rpm_path).hexdigest()
    rpm_info['size'] = os.path.getsize(rpm_path)
    rpm_info['package_basename'] = os.path.basename(rpm_path)
    rpm_fd.close()
    return rpm_info
347213
def deg2fmt(ra_deg, dec_deg, format):
    """"""

    rhr, rmn, rsec = degToHms(ra_deg)
    dsgn, ddeg, dmn, dsec = degToDms(dec_deg)

    if format == 'hms':
        return rhr, rmn, rsec, dsgn, ddeg, dmn, dsec

    elif format == 'str':
        #ra_txt = '%02d:%02d:%06.3f' % (rhr, rmn, rsec)
        ra_txt = '%d:%02d:%06.3f' % (rhr, rmn, rsec)
        if dsgn < 0:
            dsgn = '-'
        else:
            dsgn = '+'
        #dec_txt = '%s%02d:%02d:%05.2f' % (dsgn, ddeg, dmn, dsec)
        dec_txt = '%s%d:%02d:%05.2f' % (dsgn, ddeg, dmn, dsec)
        return ra_txt, dec_txt
328563
def is_rpm(path):
    

    import magic
    m = magic.open(magic.MAGIC_MIME)
    m.load()
    mime = m.file(path)
    # rpms or directories are cool
    if 'rpm' in mime or 'directory' in mime:
        return True
    else:
        juicer.utils.Log.log_info("error: File `%s` is not an rpm" % path)
        return False
137956
def string(self, writesize=None):
        '''
        
        '''
        if not self.finished:
            self.finished = True
            return self.content
        return ''
861020
def String(length=None, **kwargs):
    """"""
    return Property(
        length=length,
        types=stringy_types,
        convert=to_string,
        **kwargs
    )
735042
def str_transmission_rate(self):
        """"""
        upstream, downstream = self.transmission_rate
        return (
            fritztools.format_num(upstream),
            fritztools.format_num(downstream)
        )
554143
def _get_fname_len(self, bufflen=128):
        """"""
        buff = self.meta.peek(bufflen)
        strlen = buff.find('\0')
        for i, b in enumerate(buff[strlen:]):
            if b != '\0':
                return strlen+i
        return bufflen
1205922
def is_rpm_installed():
    """"""
    try:
        version_result = subprocess.run(["rpm", "--usage"],
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)
        rpm_installed = not version_result.returncode
    except FileNotFoundError:
        rpm_installed = False
    return rpm_installed