Get storage info

        :param bool human: whether return human-readable size
        :return: total and used storage
        :rtype: dict
483243
def get_storage_info(self, human=False):
        
        res = self._req_get_storage_info()
        if human:
            res['total'] = humanize.naturalsize(res['total'], binary=True)
            res['used'] = humanize.naturalsize(res['used'], binary=True)
        return res
917354
def size(self):
        
        return int(self._client.hget(self._bucket_key, self.key_prefix) or 0)
907192
def get_memory_usage(self, variables = None):
        
        result = dict(
            total_nb_bytes = 0,
            by_variable = {}
            )
        for entity in self.populations.values():
            entity_memory_usage = entity.get_memory_usage(variables = variables)
            result['total_nb_bytes'] += entity_memory_usage['total_nb_bytes']
            result['by_variable'].update(entity_memory_usage['by_variable'])
        return result
1350089
def memory_usage():
    
    try:
        import psutil
        import os
    except ImportError:
        return _memory_usage_ps()

    process = psutil.Process(os.getpid())
    mem = process.memory_info()[0] / float(2 ** 20)
    return mem
639302
def get_storage(self, storage):
        
        res = self.get_request('/storage/' + str(storage))
        return Storage(cloud_manager=self, **res['storage'])
280847
def human_size(size_bytes, precision=0):
    
    if size_bytes == 1:
        # because I really hate unnecessary plurals
        return "1 byte"

    suffixes_table = [('bytes',0),('KB',0),('MB',1),('GB',2),('TB',2), ('PB',2)]

    num = float(size_bytes)
    for suffix, precision in suffixes_table:
        if num < 1024.0:
            break
        num /= 1024.0

    if precision == 0:
        formatted_size = "%d" % num
    else:
        formatted_size = str(round(num, ndigits=precision))

    return "%s %s" % (formatted_size, suffix)
282531
def number_to_human_size(number, options = {})
      options.symbolize_keys!

      number = begin
        Float(number)
      rescue ArgumentError, TypeError
        if options[:raise]
          raise # InvalidNumberError, number
        else
          return number
        end
      end

      defaults = ::I18n.translate(:'number.format', :locale => options[:locale], :default => {})
      human    = ::I18n.translate(:'number.human.format', :locale => options[:locale], :default => {})
      defaults = defaults.merge(human)

      options = options.reverse_merge(defaults)
      #for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files
      options[:strip_insignificant_zeros] = true if not options.key?(:strip_insignificant_zeros)

      storage_units_format = ::I18n.translate(:'number.human.storage_units.format', :locale => options[:locale], :raise => true)

      base = options[:prefix] == :si ? 1000 : 1024

      if number.to_i < base
        unit = ::I18n.translate(:'number.human.storage_units.units.byte', :locale => options[:locale], :count => number.to_i, :raise => true)
        storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, unit).html_safe
      else
        max_exp  = STORAGE_UNITS.size - 1
        exponent = (Math.log(number) / Math.log(base)).to_i # Convert to base
        exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit
        number  /= base ** exponent

        unit_key = STORAGE_UNITS[exponent]
        unit = ::I18n.translate(:"number.human.storage_units.units.#{unit_key}", :locale => options[:locale], :count => number, :raise => true)

        formatted_number = number_with_precision(number, options)
        storage_units_format.gsub(/%n/, formatted_number).gsub(/%u/, unit).html_safe
      end
    end
316084
def capacity(self):
        
        _complain_ifclosed(self.closed)
        if not self.__status.host:
            raise RuntimeError('Capacity is not defined for a local fs')
        return self.fs.get_capacity()
951810
def data_size(self, live_data=None):
        """"""
        if live_data is not None:
            warnings.warn("The 'live_data' keyword argument is deprecated.",
                          DeprecationWarning)
        output = self.nodetool('info')[0]
        return _get_load_from_info_output(output)
1250044
def size(self):
        
        if hasattr(self._stream, 'len'):
            return len(self._stream)
        elif hasattr(self._stream, 'fileno'):
            return os.fstat(self._stream.fileno()).st_size
        else:
            cur_pos = self._stream.tell()
            size = self._stream.seek(0, os.SEEK_END)
            self._stream.seek(cur_pos)
            return size
346337
def size(self):
        ''''''
        if self.cache.cache is None:
            return self.read_backend_structure().size()
        else:
            return len(self.cache.cache)
1178665
def calculate_size(name, count):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += INT_SIZE_IN_BYTES
    return data_size
1282273
def _unit_info(self) -> Tuple[str, int]:
        
        abs_bytes = abs(self.size)
        if abs_bytes < 1024:
            unit = 'B'
            unit_divider = 1
        elif abs_bytes < (1024 ** 2):
            unit = 'KB'
            unit_divider = 1024
        elif abs_bytes < (1024 ** 3):
            unit = 'MB'
            unit_divider = (1024 ** 2)
        elif abs_bytes < (1024 ** 4):
            unit = 'GB'
            unit_divider = (1024 ** 3)
        else:
            unit = 'TB'
            unit_divider = (1024 ** 4)

        return unit, unit_divider
1228563
def size(args):
    
    from jcvi.utils.cbook import human_size

    p = OptionParser(size.__doc__)
    fp = sys.stdin

    results = []
    for link_name in fp:
        link_name = link_name.strip()
        if not op.islink(link_name):
            continue

        source = get_abs_path(link_name)

        link_name = op.basename(link_name)
        filesize = op.getsize(source)
        results.append((filesize, link_name))

    # sort by descending file size
    for filesize, link_name in sorted(results, reverse=True):
        filesize = human_size(filesize, a_kilobyte_is_1024_bytes=True)
        print("%10s\t%s" % (filesize, link_name), file=sys.stderr)
989880
def get_total_memory():
    """"""
    if platform.system() != "Linux":
        return None

    with open("/proc/meminfo", "r") as in_file:
        for line in in_file:
            info = line.split()
            if info[0] == "MemTotal:" and info[-1] == "kB":
                memory_mb = int(int(info[1]) / 1024)
                return memory_mb

    return None
1026045
def get_readable_filesize(size):
	
	if(size < 1024):
		return str(size)+' bytes'
	temp = size/1024.0
	level = 1
	while(temp >= 1024 and level< 3):
		temp = temp/1024
		level += 1
	if(level == 1):
		return str(round(temp,2))+' KB'
	elif(level == 2):
		return str(round(temp,2))+' MB'
	else:
		return str(round(temp,2))+' GB'
117788
def size(self):
        
        if self._size is None:
            self._size = sum(s.len for s in self.statements if type(s) is stmt.IMark)
        return self._size