def CanMonitorPower(self):
        family, model = map(int, re.match(".+ Family ([0-9]+) Model ([0-9]+)", platform.processor()).groups())
        if not _IsSandyBridgeOrLater(platform.processor(), family, model):
            logging.info("Cannot monitor power: pre-Sandy Bridge CPU.")
            return False

        return self._CheckMSRs()
  def CanMonitorPower(self):
    if not win32event:
      return False

    # TODO(dtu): This should work on Windows 7, but it's flaky on the bots.
    # http://crbug.com/336558
    windows_8_or_later = (
        self._backend.GetOSName() == 'win' and
        self._backend.GetOSVersionName() >= platform_backend.WIN8)
    if not windows_8_or_later:
      return False

    # This check works on Windows only.
    family, model = map(int, re.match('.+ Family ([0-9]+) Model ([0-9]+)',
                        platform.processor()).groups())
    # Model numbers from:
    # https://software.intel.com/en-us/articles/intel-architecture-and-processor-identification-with-cpuid-model-and-family-numbers
    # http://www.speedtraq.com
    sandy_bridge_or_later = ('Intel' in platform.processor() and family == 6 and
                             (model in (0x2A, 0x2D) or model >= 0x30))
    if not sandy_bridge_or_later:
      return False

    if not IppetPath():
      return False

    return True
Beispiel #3
0
def performance(attribute):
    """ A little smater routing system.
    """

    data = None

    if attribute == 'system':
        data = { 'system': platform.system() }
    elif attribute == 'processor':
        data = { 'processor': platform.processor() }
    elif attribute in ['cpu_count', 'cpucount'] :
        data = { 'cpu_count': psutil.cpu_count() }
    elif attribute == 'machine':
        data = { 'machine': platform.machine() }
    elif attribute in ['virtual_mem', 'virtualmem']:
        data = { 'virtual_mem': psutil.virtual_memory().total }
    elif attribute in ['virtual_mem_gb', 'virtualmemgb']:
        data = { 'virtual_mem_gb': psutil.virtual_memory().total / (1024.0 ** 3) }
    elif attribute == 'all':
        data = {
            'system': platform.system(),
            'processor': platform.processor(),
            'cpu_count': psutil.cpu_count(),
            'machine': platform.machine(),
            'virtual_mem': psutil.virtual_memory().total,
            'virtual_mem_gb': psutil.virtual_memory().total / (1024.0 ** 3),
        }

    packet = json.dumps(data)
    resp = Response(packet, status=200, mimetype='application/json')

    return(resp)
Beispiel #4
0
    def _get_processor(self):
        '''Get type of processor
        http://stackoverflow.com/questions/4842448/getting-processor-information-in-python
        '''
        out = None
        if platform.system() == "Windows":
            out = platform.processor()
        elif platform.system() == "Darwin":
            path = os.environ['PATH']
            os.environ['PATH'] = os.environ['PATH'] + os.pathsep + '/usr/sbin'
            try:
                command = "sysctl -n machdep.cpu.brand_string"
                out = subprocess.check_output(command, shell=True).strip().decode()
            finally:
                os.environ['PATH'] = path
        elif platform.system() == "Linux":
            command = "cat /proc/cpuinfo"
            all_info = subprocess.check_output(command, shell=True).strip().decode()
            for line in all_info.split("\n"):
                if "model name" in line:
                    out = re.sub(".*model name.*:", "", line, 1)

        if out is None:
            return platform.processor()
        else:
            return out
Beispiel #5
0
  def CanMonitorPower(self):
    # IPPET disabled because of flakiness (crbug.com/336558).
    if True:
      return False

    if not win32event:
      return False

    windows_7_or_later = (
        self._backend.GetOSName() == 'win' and
        self._backend.GetOSVersionName() >= platform_backend.WIN7)
    if not windows_7_or_later:
      return False

    # This check works on Windows only.
    family, model = map(int, re.match('.+ Family ([0-9]+) Model ([0-9]+)',
                        platform.processor()).groups())
    # Model numbers from:
    # https://software.intel.com/en-us/articles/intel-architecture-and- \
    # processor-identification-with-cpuid-model-and-family-numbers
    # http://www.speedtraq.com
    sandy_bridge_or_later = ('Intel' in platform.processor() and family == 6 and
                             (model in (0x2A, 0x2D) or model >= 0x30))
    if not sandy_bridge_or_later:
      return False

    if not IppetPath():
      return False

    return True
Beispiel #6
0
def getArch() :
  """
  Return the NuPIC architecture name.
  Note that this is redundant with the calculation in configure.ac
  """
  if sys.platform == "linux2":
    #
    # platform.processor() vs. platform.machine() is a bit of a mystery
    # On linux systems, they ultimately translate to uname -p and uname -m, respectively.
    # These options and their possible results aren't clearly documented. 
    # uname -p doesn't exist in some versions of uname (debian 3.x)
    # and returns "unknown" on others (Ubuntu). Python translates "unknown" to "". 
    # uname -p may also return "athlon" or other random words. 
    # 
    cpu = platform.machine()
    if cpu not in ["i686", "i386", "x86_64"]:
      cpu = platform.processor()
    if cpu in ["i686", "i386"]:
      return "linux32"
    elif cpu == "x86_64":
      return "linux64"
    else:
      raise Exception("Unknown cpu for linux system. platform.machine() = %s; platform.processor() = %s" % (platform.machine(), platform.processor()))
  elif sys.platform == "darwin":
    cpu = platform.processor()
    if cpu == "powerpc":
      raise Exception("Unsupported CPU %s for darwin system" %(cpu));
    else:
      return "darwin64"

  elif sys.platform == "win32":
    return "win32"
  else:
    raise Exception("Unknown os %s" % sys.platform)
    def __init__(self, main_win, target_controller, x86_slice_mode=False):
        super(PartEditScreen, self).__init__(main_win)

        global LOGGER
        LOGGER = logging.getLogger(INSTALL_LOGGER_NAME)

        self.x86_slice_mode = x86_slice_mode
        self.is_x86 = (platform.processor() == "i386")
        self.header_text = platform.processor()
        
        if self.x86_slice_mode: # x86, Slice within a partition
            self.instance = ".slice"
            self.header_text = PartEditScreen.HEADER_x86_SLICE
            self.paragraph_text = PartEditScreen.SLICE_PARAGRAPH
            self.destroy_text = PartEditScreen.SLICE_DESTROY_TEXT
            self.help_data = PartEditScreen.X86_SLICE_HELP
        elif self.is_x86: # x86, Partition on disk
            self.header_text = PartEditScreen.HEADER_x86_PART
            self.paragraph_text = PartEditScreen.PARTITION_PARAGRAPH
            self.destroy_text = PartEditScreen.PART_DESTROY_TEXT
            self.help_data = PartEditScreen.X86_PART_HELP
        else: # SPARC (Slice on disk)
            self.header_text = PartEditScreen.HEADER_SPARC_SLICE
            self.paragraph_text = PartEditScreen.SLICE_PARAGRAPH
            self.destroy_text = PartEditScreen.SLICE_DESTROY_TEXT
            self.help_data = PartEditScreen.SPARC_HELP
            self.help_format = "  %s"
        
        self.disk_win = None
        self.tc = target_controller
Beispiel #8
0
    def platform_infos(self):
        # (TT) codice clandestino di prova
        #http://www.doughellmann.com/PyMOTW/resource/
        #print "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        #try:
        #    import resource
        #    print "res0", resource.getrusage(0)
        #    print "res1",  resource.getrusage(1)
        #except ImportError:
        #    print "miu mio!"
        #print "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

        from src.engine import engine

        lines = []
        dt = datetime.datetime.now()
        lines.append("Platform infos on %d %d %d" % (dt.year, dt.month, dt.day))
        lines.append("Bit Architecture: %s" % str(platform.architecture()))
        lines.append("Machine Type: %s" % platform.machine())
        lines.append("Network Node: %s" % platform.node())
        if platform.processor():
            lines.append("(Real) Processor: %s" % platform.processor())
        lines.append("System Name: %s" % platform.system())
        lines.append("System Version: %s" % platform.version())
        lines.append("System Release: %s" % platform.release())
        if any(platform.dist()):
            lines.append("Linux Distribution: %s" % str(platform.dist()))
        if any(platform.libc_ver()):
            lines.append("Linux Libc Version: %s" % str(platform.libc_ver()))
        lines.append("Python Build: %s" % str(platform.python_build()))
        lines.append("Python Compiler: %s" % platform.python_compiler())
        lines.append("Python Version: %s" % platform.python_version())
        lines.append("Python Executable: %s" % sys.executable)
        lines.append("Twisted Version: %s" % twisted_version.base())
        if engine.epoll:
            lines.append("Reactor: epoll")
        else:
            lines.append("Reactor: select")
        lines.append("PIL Version: %s" % Image.VERSION)
        if numpy_version:
            lines.append("Numpy Version: %s" % numpy_version)
        lines.append("\n")
        lines = "\n".join(lines)

        filename = "log/platform_infos.txt"
        try:
            platform_log_file = open(filename, "a")
            platform_log_file.write(lines + "\n")
            platform_log_file.close()
        except IOError:
            print "Impossibile aprire il file %s in scrittura" % filename

        print lines
Beispiel #9
0
  def CanMonitorPower(self):
    family, model = map(int, re.match('.+ Family ([0-9]+) Model ([0-9]+)',
                        platform.processor()).groups())
    if not _IsSandyBridgeOrLater(platform.processor(), family, model):
      logging.info('Cannot monitor power: pre-Sandy Bridge CPU.')
      return False

    try:
      return self._CheckMSRs()
    finally:
      # Since _CheckMSRs() starts the MSR server on win platform, we must close
      # it after checking to avoid leaking msr server process.
      self._backend.CloseMsrServer()
Beispiel #10
0
def get_system_stats():
    systemStats = {
        'machine': platform.machine(),
        'platform': sys.platform,
        'processor': platform.processor(),
        'pythonV': platform.python_version(),
    }

    platf = sys.platform
    
    if  Platform.is_linux(platf):
        grep = subprocess.Popen(['grep', 'model name', '/proc/cpuinfo'], stdout=subprocess.PIPE, close_fds=True)
        wc = subprocess.Popen(['wc', '-l'], stdin=grep.stdout, stdout=subprocess.PIPE, close_fds=True)
        systemStats['cpuCores'] = int(wc.communicate()[0])

    if Platform.is_darwin(platf):
        systemStats['cpuCores'] = int(subprocess.Popen(['sysctl', 'hw.ncpu'], stdout=subprocess.PIPE, close_fds=True).communicate()[0].split(': ')[1])

    if Platform.is_freebsd(platf):
        systemStats['cpuCores'] = int(subprocess.Popen(['sysctl', 'hw.ncpu'], stdout=subprocess.PIPE, close_fds=True).communicate()[0].split(': ')[1])

    if Platform.is_linux(platf):
        systemStats['nixV'] = platform.dist()

    elif Platform.is_darwin(platf):
        systemStats['macV'] = platform.mac_ver()

    elif Platform.is_freebsd(platf):
        version = platform.uname()[2]
        systemStats['fbsdV'] = ('freebsd', version, '')  # no codename for FreeBSD

    elif Platform.is_win32(platf):
        systemStats['winV'] = platform.win32_ver()

    return systemStats
Beispiel #11
0
def index():
    """ The main Flask entry-point (/) for the Stallion server. """
    data = {"breadpath": [Crumb("Main")]}

    data.update(get_shared_data())
    data["menu_home"] = "active"

    sys_info = {
        "Python Platform": sys.platform,
        "Python Version": sys.version,
        "Python Prefix": sys.prefix,
        "Machine Type": platform.machine(),
        "Platform": platform.platform(),
        "Processor": platform.processor(),
    }

    try:
        sys_info["Python Implementation"] = platform.python_implementation()
    except:
        pass

    sys_info["System"] = platform.system()
    sys_info["System Arch"] = platform.architecture()

    data["system_information"] = sys_info

    return render_template("system_information.html", **data)
Beispiel #12
0
    def __repr__(self):
        import platform
        from itertools import chain

        out = []
        out += ['PyAbel benchmark run on {}\n'.format(platform.processor())]

        LABEL_FORMAT =     '|'.join([' Implementation '] \
                + ['    n = {:<12} '.format(ni) for ni in self.n])
        TR_ROW_FORMAT = '|'.join(['{:>15} '] + [ ' {:8.1e}            ' ]*len(self.n))
        BS_ROW_FORMAT = '|'.join(['{:>15} '] + [ ' {:8.1e} ({:8.1e}) ' ]*len(self.n))
        SEP_ROW = ' ' + '-'*(22 + (17+1)*len(self.n))

        HEADER_ROW = ' ========= {:>10} Abel implementations ==========\n' \
                ' time to solution [s] -> transform (basis sets generation)\n'


        def print_benchmark(name, res):
            out = [HEADER_ROW.format(name)]
            if res:
                out += [LABEL_FORMAT]
                out += [SEP_ROW]
                for name, row  in res.items():
                    if 'bs' in row:
                        pars = list(chain(*zip(row['tr'], row['bs'])))
                        out += [BS_ROW_FORMAT.format(name, *pars)]
                    else:
                        out += [TR_ROW_FORMAT.format(name, *row['tr'])]
            return out

        out += print_benchmark('Direct', self.fabel)
        out += ['']
        out += print_benchmark('Inverse', self.iabel)

        return '\n'.join(out)
def download_node(node_directory, node_version=None):
    node_exe = os.path.join(node_directory, "node")
    if os.path.lexists(node_exe):
        print "Doing nothing as %s exists" % node_exe
        return os.path.realpath(node_exe)

    if not node_version:
        json_file = urllib.urlopen("https://nodejs.org/download/release/index.json").read()
        versions = json.loads(json_file)
        lts_versions = [x["version"] for x in versions if x["lts"]]
        lts_versions.sort(reverse=True)
        node_version = lts_versions[0]

    arch_mappings = {
        "x86_64": "x64",
        "x86": "x86"
    }
    arch = arch_mappings[platform.processor()]
    download_url = "https://nodejs.org/download/release/{0}/node-{0}-linux-{1}.tar.gz".format(node_version,arch)

    if not os.path.exists(node_directory):
        os.mkdir(node_directory)

    node_extract_path = os.path.join(node_directory, "node-{0}-linux-{1}".format(node_version, arch), "bin", "node")
    node_download_file = os.path.join(node_directory, "node-{0}-linux-{1}.tar.gz".format(node_version, arch))

    url_downloader = urllib.URLopener()
    url_downloader.retrieve(download_url, node_download_file)

    tar = tarfile.open(node_download_file)
    tar.extractall(path=node_directory)

    os.symlink(os.path.abspath(node_extract_path), node_exe)
    return os.path.realpath(node_exe)
Beispiel #14
0
def print_platform_info():
    import platform
    logging.debug('*************** PLATFORM INFORMATION ************************')
    
    logging.debug('==Interpreter==')
    logging.debug('Version      :' + platform.python_version())
    logging.debug('Version tuple:' + str(platform.python_version_tuple()))
    logging.debug('Compiler     :' + platform.python_compiler())
    logging.debug('Build        :' + str(platform.python_build()))
    
    logging.debug('==Platform==')
    logging.debug('Normal :' + platform.platform())
    logging.debug('Aliased:' + platform.platform(aliased=True))
    logging.debug('Terse  :' + platform.platform(terse=True))
    
    logging.debug('==Operating System and Hardware Info==')
    logging.debug('uname:' + str(platform.uname()))
    logging.debug('system   :' + platform.system())
    logging.debug('node     :' + platform.node())
    logging.debug('release  :' + platform.release())
    logging.debug('version  :' + platform.version())
    logging.debug('machine  :' + platform.machine())
    logging.debug('processor:' + platform.processor())
    
    logging.debug('==Executable Architecture==')
    logging.debug('interpreter:' + str(platform.architecture()))
    logging.debug('/bin/ls    :' + str(platform.architecture('/bin/ls')))
    logging.debug('*******************************************************')
Beispiel #15
0
def test_compilation(cfile, compiler=None, **compiler_attrs):
    """Test simple compilation with given settings"""
    cc = get_compiler(compiler, **compiler_attrs)

    efile, ext = os.path.splitext(cfile)

    cpreargs = lpreargs = []
    if sys.platform == 'darwin':
        # use appropriate arch for compiler
        if platform.architecture()[0]=='32bit':
            if platform.processor() == 'powerpc':
                cpu = 'ppc'
            else:
                cpu = 'i386'
            cpreargs = ['-arch', cpu]
            lpreargs = ['-arch', cpu, '-undefined', 'dynamic_lookup']
        else:
            # allow for missing UB arch, since it will still work:
            lpreargs = ['-undefined', 'dynamic_lookup']
    if sys.platform == 'sunos5':
        if platform.architecture()[0]=='32bit':
            lpreargs = ['-m32']
        else:
            lpreargs = ['-m64']
    extra = compiler_attrs.get('extra_compile_args', [])
    extra += ['--std=c++11']

    objs = cc.compile([cfile], extra_preargs=cpreargs, extra_postargs=extra)
    cc.link_executable(objs, efile, extra_preargs=lpreargs)
    return efile
Beispiel #16
0
def get_depends(args):
	for package in args: # For each package in the list of arguments
		try:
			tmp = tuple(package.split(":")) # Ethan wrote this
			parameters =  tmp + (None,) * (3 - len(tmp)) # This converts the "name:version:arch" into a tuple

			package = { # This converts the tuple into a dictionary so we can use default values
				"name": parameters[0],
				"version": parameters[1] if parameters[1] != None else "Latest", # If there is no second value, set the value of "version" to "Latest"
				"arch": parameters[2] if parameters[2] != None else platform.processor() # If there is no third value, set "arch" to the current processor
			}
			
			if not database.TableExists(package["name"]): # 	If the package doesn't exist, throw an error
				raise Exception("Package doesn't exist in database.")	
			
			for version in database.Dump(package["name"]): # 	For each version of that package
				if version["Version"] == package["version"]: # 	If this is the version we're attempting to install
					if version["Version"] != "Latest": #		and it's not "Latest"
						screen.write_line(version["Dependencies"] + "\n") # FIXME CHANGEME TODO print the dependencies
					else: #										On the other hand, if this IS "Latest"
						for version_ in database.Dump(package["name"]): # For each version in the package
							if version_["Version"] == version["LatestVersion"]: # If this is the latest version
								screen.write_line(str(version_["Dependencies"]) + "\n") # FIXME CHANGEME TODO print the dependencies
			print(package["name"], package["version"], package["arch"], "\n") # FIXME CHANGEME TODO print the package name, version and arch
		except:
			print("Failed to locate package " + package["name"] + ":" + package["version"] + ":" + package["arch"])
			print(traceback.format_exc())
Beispiel #17
0
def get_machine_details():

    if _debug:
        print 'Getting machine details...'
    buildno, builddate = platform.python_build()
    python = platform.python_version()
    try:
        unichr(100000)
    except ValueError:
        # UCS2 build (standard)
        unicode = 'UCS2'
    except NameError:
        unicode = None
    else:
        # UCS4 build (most recent Linux distros)
        unicode = 'UCS4'
    bits, linkage = platform.architecture()
    return {
        'platform': platform.platform(),
        'processor': platform.processor(),
        'executable': sys.executable,
        'implementation': getattr(platform, 'python_implementation',
                                  lambda:'n/a')(),
        'python': platform.python_version(),
        'compiler': platform.python_compiler(),
        'buildno': buildno,
        'builddate': builddate,
        'unicode': unicode,
        'bits': bits,
        }
 def setUp(self):
     """
     Get the number of cores and threads per core
     Set the SMT value to 4/8
     """
     if 'ppc' not in platform.processor():
         self.cancel("Processor is not ppc64")
     self.nfail = 0
     self.CORES = process.system_output("lscpu | grep 'Core(s) per socket:'"
                                        "| awk '{print $4}'", shell=True)
     self.SOCKETS = process.system_output("lscpu | grep 'Socket(s):'"
                                          "| awk '{print $2}'", shell=True)
     self.THREADS = process.system_output("lscpu | grep 'Thread(s) per core"
                                          ":'| awk '{print $4}'",
                                          shell=True)
     self.T_CORES = int(self.CORES) * int(self.SOCKETS)
     self.log.info(" Cores = %s and threads = %s "
                   % (self.T_CORES, self.THREADS))
     process.system("echo 8 > /proc/sys/kernel/printk", shell=True,
                    ignore_status=True)
     self.max_smt = 4
     if cpu.get_cpu_arch().lower() == 'power8':
         self.max_smt = 8
     if cpu.get_cpu_arch().lower() == 'power6':
         self.max_smt = 2
     process.system_output("ppc64_cpu --smt=%s" % self.max_smt, shell=True)
     self.path = "/sys/devices/system/cpu"
Beispiel #19
0
    def set_properties(self):
        self._properties = SortedDict()
        if LSB:
            self.add_property(Property('is_lsb', _(u'LSB OS'), True))
            self.add_property(Property('distributor_id', _(u'Distributor ID'), lsb_release('-i','-s')))
            self.add_property(Property('description', _(u'Description'), lsb_release('-d','-s')))
            self.add_property(Property('release', _(u'Release'), lsb_release('-r','-s')))
            self.add_property(Property('codename', _(u'Codename'), lsb_release('-c','-s')))
            self.add_property(Property('sysinfo', _(u'System info'), uname('-a')))
        else:
            self.add_property(Property('is_posix', _(u'POSIX OS'), False))

        self.add_property(Property('architecture', _(u'OS architecture'), platform.architecture()))
        self.add_property(Property('python_version', _(u'Python version'), platform.python_version()))
        self.add_property(Property('hostname', _(u'Hostname'), platform.node()))
        self.add_property(Property('platform', _(u'Platform'), sys.platform))
        self.add_property(Property('machine', _(u'Machine'), platform.machine()))
        self.add_property(Property('processor', _(u'Processor'), platform.processor()))
        self.add_property(Property('cpus', _(u'Number of CPUs'), psutil.NUM_CPUS))
        self.add_property(Property('total_phymem', _(u'Total physical memory'), pretty_size(psutil.TOTAL_PHYMEM)))
        self.add_property(Property('disk_partitions', _(u'Disk partitions'), '; '.join(['%s %s %s %s' % (partition.device, partition.mountpoint, partition.fstype, partition.opts) for partition in psutil.disk_partitions()])))
        
        try:
            self.add_property(Property('tesseract', _(u'tesseract version'), pbs.tesseract('-v').stderr))
        except pbs.CommandNotFound:
            self.add_property(Property('tesseract', _(u'tesseract version'), _(u'not found')))

        try:
            self.add_property(Property('unpaper', _(u'unpaper version'), pbs.unpaper('-V').stdout))
        except pbs.CommandNotFound:
            self.add_property(Property('unpaper', _(u'unpaper version'), _(u'not found')))
Beispiel #20
0
def _get_system_provenance():
    """ return JSON string containing provenance for all things that are
    fixed during the runtime"""

    bits, linkage = platform.architecture()

    return dict(
        ctapipe_version=ctapipe.__version__,
        ctapipe_resources_version=ctapipe_resources.__version__,
        ctapipe_svc_path=os.getenv("CTAPIPE_SVC_PATH"),
        executable=sys.executable,
        platform=dict(
            architecture_bits=bits,
            architecture_linkage=linkage,
            machine=platform.machine(),
            processor=platform.processor(),
            node=platform.node(),
            version=platform.version(),
            system=platform.system(),
            release=platform.release(),
            libcver=platform.libc_ver(),
            num_cpus=psutil.cpu_count(),
            boot_time=Time(psutil.boot_time(), format='unix').isot,
        ),
        python=dict(
            version_string=sys.version,
            version=platform.python_version_tuple(),
            compiler=platform.python_compiler(),
            implementation=platform.python_implementation(),
        ),
        arguments=sys.argv,
        start_time_utc=Time.now().isot,
    )
def get_platform_info(output_file):
    print("\nSYSTEM INFORMATION", file=output_file)
    print("{:<20}{:>5}".format('system:', platform.system()), file=output_file)
    print("{:<20}{:>5}".format('node:', platform.node()), file=output_file)
    print("{:<20}{:>5}".format('version:', platform.version()), file=output_file)
    print("{:<20}{:>5}".format('processor:', platform.processor()), file=output_file)
    print("{:<20}{:>5}".format("python compiler:", platform.python_compiler()), file=output_file)
def runCommands():
    tmp_dir="./tmp_install"
    os.chdir(tmp_dir)
    cpu_info=platform.processor()
    #Iterates over list, running statements for each item in the list
    color="YELLOW"
    temp_message= "Start operation for Redis installation:"
    print (colorstr(temp_message, color))
    for cmd in cmds_redis:
        subprocess.call(cmd, shell=True)
    temp_message= "I found this CPU class: "+cpu_info
    print (colorstr(temp_message, color))
    if cpu_info == "x86_64":
        temp_message= "Starting 64Bit installation of WkhtmlToPdf:"
        print (colorstr(temp_message, color))
        for cmd in cmds_wkhtml_64:
            subprocess.call(cmd, shell=True)
    else:
        temp_message= "Starting installation of 32Bit version of WkhtmlToPdf:"
        print (colorstr(temp_message, color))
        for cmd in cmds_wkhtml_32:
            subprocess.call(cmd, shell=True)
    os.chdir("../")
    try:
        shutil.rmtree(tmp_dir)  # delete directory
    except OSError as exc:
        if exc.errno != 2:  # code 2 - no such file or directory
            raise  # re-raise exception
Beispiel #23
0
def _get_build_platform():
    plat = pkg_resources._get_build_platform()
    if sys.platform == 'darwin':
        # Assert OS X version is new enough
        current_minor_ver = int( platform.mac_ver()[0].split( '.' )[1] )
        assert current_minor_ver >= 6, 'Galaxy is not compatible with Mac OS X < 10.6 (your version is %s)' % platform.mac_ver()[0]
        # Python build target may be even older, but this will prevent it from
        # fetching our 10.6+ eggs, so fix if necessary (newer versions will be
        # fine)
        plat_split = plat.split( '-' )
        build_minor_ver = int( plat_split[1].split( '.' )[1] )
        if build_minor_ver < 6:
            plat_split[1] = '10.6'
        # Our intel (dual arch) eggs will work fine on single-arch builds
        if plat_split[-1] in ( 'i386', 'x86_64' ):
            plat_split[-1] = 'intel'
        # Ditto universal (if you're not on PPC)
        if plat_split[-1] == 'universal' and platform.processor() != 'powerpc':
            plat_split[-1] = 'intel'
        plat = '-'.join( plat_split )
    elif sys.platform == "linux2" and sys.maxint < 2 ** 31 and plat.endswith( '-x86_64' ):
        # 32 bit Python on 64 bit Linux
        plat = plat.replace( '-x86_64', '-i686' )
    if not (plat.endswith('-ucs2') or plat.endswith('-ucs4')):
        if sys.maxunicode > 2 ** 16:
            plat += '-ucs4'
        else:
            plat += '-ucs2'
    return plat
Beispiel #24
0
def pull_os():
  """Find information about the host's operating system.

  Returns:
    A tuple of a dictionary of the OS information, and the system's processor.

    Example:
    (
     {
       'architecture': 'nt',
        'platform': 'Windows',
        'release': {
          'product_name': 'Windows 8',
          'service_pack': 0,
          'version_number': '6.2'
      },
     'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel'
    )
  """

  os_info = {}
  os_info['architecture'] = os.name
  os_info['platform'] = hiveary.info.current_system
  if hiveary.info.current_system == 'Windows':
    os_info['release'] = wincom.get_version_info()
  else:
    os_info['release'] = platform.release()

  processor = platform.processor()

  return (os_info, processor)
Beispiel #25
0
def get_info_in_json():
        json_str="{\n"
        json_str+=" \"os\":\""+platform.system()+"\",\n"
        json_str+=" \"processor\":\""+platform.processor()+"\",\n"
        json_str+=" \"release\":\""+platform.release()+"\",\n"
        json_str+=" \"uname\":\""
        items=platform.uname()
        for item in items:
                json_str+=item+";"
        json_str+="\",\n"
        items=platform.linux_distribution()
        json_str+=" \"distro\":\""
        for item in items:
                json_str+=item+";"
        json_str+="\",\n"
        items=platform.libc_ver()
        json_str+=" \"libc\":\""
        for item in items:
                json_str+=item+";"
        json_str+="\",\n"
        json_str+=" \"tram\":\""+get_total_ram()+"\",\n"
        json_str+=" \"ncpu\":\""+str(multiprocessing.cpu_count())+"\",\n"
        json_str+=" \"uptime\":\""+get_uptime()+"\",\n"
        json_str+=" \"date\":\""+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+"\",\n"
        json_str+=" \"badips\":\""+get_banned_ip_address()+"\",\n"
        json_str+=" \"load\":\""+get_load()+"\"\n"
        json_str+="}\n"
        return json_str
Beispiel #26
0
def device_spec():
    print(platform.machine())
    print(platform.version())
    print(platform.platform())
    print(platform.uname())
    print(platform.system())
    print(platform.processor())
Beispiel #27
0
def debug_details():
    """ Show detailed version/debugging information. """
    import platform
    logging.info('\nPLATFORM')
    logging.info('os: %s %s %s', plat.system, platform.processor(), platform.version())
    logging.info('python: %s %s', sys.version.replace('\n',''), ' '.join(platform.architecture()))
    logging.info('\nMODULES')
    # try numpy before pygame to avoid strange ImportError on FreeBSD
    modules = ('numpy', 'win32api', 'pygame', 'curses', 'pexpect', 'serial', 'parallel')
    for module in modules:
        try:
            m = __import__(module)
        except ImportError:
            logging.info('%s: --', module)
        else:
            for version_attr in ('__version__', 'version', 'VERSION'):
                try:
                    version = getattr(m, version_attr)
                    logging.info('%s: %s', module, version)
                    break
                except AttributeError:
                    pass
            else:
                logging.info('available\n')
    if plat.system != 'Windows':
        logging.info('\nEXTERNAL TOOLS')
        tools = ('lpr', 'paps', 'beep', 'xclip', 'xsel', 'pbcopy', 'pbpaste')
        for tool in tools:
            try:
                location = subprocess.check_output('command -v %s' % tool, shell=True).replace('\n','')
                logging.info('%s: %s', tool, location)
            except Exception as e:
                logging.info('%s: --', tool)
Beispiel #28
0
def get_debug_info(civcoms):
    code = "<html><head><meta http-equiv=\"refresh\" content=\"20\">" \
       + "<link href='/css/bootstrap.min.css' rel='stylesheet'></head>" \
       + "<body><div class='container'>" \
       + "<h2>Freeciv WebSocket Proxy Status</h2>" \
       + "<font color=\"green\">Process status: OK</font><br>"

    code += "<b>Process Uptime: " + \
        str(int(time.time() - startTime)) + " s.</b><br>"

    code += ("Python version: %s %s (%s)<br>" % (
        platform.python_implementation(),
        platform.python_version(),
        platform.python_build()[0],
    ))

    cpu = ' '.join(platform.processor().split())
    code += ("Platform: %s %s on '%s' <br>" % (
        platform.machine(),
        platform.system(),
        cpu))

    code += ("Tornado version %s <br>" % (tornado_version))

    try:
        f = open("/proc/loadavg")
        contents = f.read()
        code += "Load average: " + contents
        f.close()
    except:
        print("Cannot open uptime file: /proc/uptime")

    try:
        code += "<h3>Memory usage:</h3>"
        code += "Memory: " + str(memory() / 1048576) + " MB <br>"
        code += "Resident: " + str(resident() / 1048576) + " MB <br>"
        code += "Stacksize: " + str(stacksize() / 1048576) + " MB <br>"
        try:
          code += "Garabage collection stats: " + str(gc.get_stats()) + " <br>"
          code += "Garabage list: " + str(gc.garbage) + " <br>"
        except AttributeError:
          pass

        code += ("<h3>Logged in users  (count %i) :</h3>" % len(civcoms))
        for key in list(civcoms.keys()):
            code += (
                "username: <b>%s</b> <br>IP:%s <br>Civserver: (%d)<br>Connect time: %d<br><br>" %
                (civcoms[key].username,
                 civcoms[key].civwebserver.ip,
                    civcoms[key].civserverport,
                    time.time() -
                    civcoms[key].connect_time))

    except:
        print(("Unexpected error:" + str(sys.exc_info()[0])))
        raise

    code += "</div></body></html>"

    return code
Beispiel #29
0
    def __init__(self, name, source_path, cmds, timeout, compiler_id = 0):
        self.name = name
        self.source_path = Test.uncygdrive(source_path)
        self.expect_path = Test.source_to_expect_path(self.source_path)
        self.source_directory, self.fname = os.path.split(self.source_path)
        self.temp_directory = os.path.join(self.source_directory, "Output")
        self.temp_output_path = os.path.join(self.temp_directory, self.fname + ".tmp")

        self.output = None
        self.expected = Test.read_normalize(self.expect_path)

        self.cmds = cmds
        self.timeout = timeout
        self.compiler_id = compiler_id
        self.cmds = [cmd.replace("%s", self.source_path) for cmd in self.cmds]
        self.cmds = [cmd.replace("%S", self.source_directory) for cmd in self.cmds]
        self.cmds = [cmd.replace("%t", self.temp_output_path) for cmd in self.cmds]
        self.cmds = [cmd.replace("%T", self.temp_directory) for cmd in self.cmds]

        self.status = TestStatus.PENDING
        self.proc_info = platform.processor()

        self.time, self.suite_time = None, None
        self.njobs, self.returncodes = None, []
        self.start, self.end, self.duration = None, None, None
Beispiel #30
0
def test_compilation(cfile, compiler=None, **compiler_attrs):
    """Test simple compilation with given settings"""
    if compiler is None or isinstance(compiler, str):
        cc = ccompiler.new_compiler(compiler=compiler)
        customize_compiler(cc)
        if cc.compiler_type == 'mingw32':
            customize_mingw(cc)
    else:
        cc = compiler

    for name, val in compiler_attrs.items():
        setattr(cc, name, val)

    efile, ext = os.path.splitext(cfile)

    cpreargs = lpreargs = None
    if sys.platform == 'darwin':
        # use appropriate arch for compiler
        if platform.architecture()[0]=='32bit':
            if platform.processor() == 'powerpc':
                cpu = 'ppc'
            else:
                cpu = 'i386'
            cpreargs = ['-arch', cpu]
            lpreargs = ['-arch', cpu, '-undefined', 'dynamic_lookup']
        else:
            # allow for missing UB arch, since it will still work:
            lpreargs = ['-undefined', 'dynamic_lookup']
    extra = compiler_attrs.get('extra_compile_args', None)

    objs = cc.compile([cfile],extra_preargs=cpreargs, extra_postargs=extra)
    cc.link_executable(objs, efile, extra_preargs=lpreargs)
    return efile
Beispiel #31
0
def get_processor():
    """计算机处理器信息"""
    return platform.processor()
# Report
# OS version
print_header_1('OS information')
print(Fore.GREEN + '[INFO]\t linux_distribution  : ' +
      ' '.join(str(p) for p in platform.linux_distribution()))
# OS Memory
print(Fore.GREEN +
      '[INFO]\t OS total memory     : {0}'.format(format_bytes(mem.total)))
print(Fore.BLUE + '[INFO]\t node                : {0}'.format(platform.node()))
print(Fore.GREEN +
      '[INFO]\t release             : {0}'.format(platform.release()))
print(Fore.BLUE +
      '[INFO]\t machine             : {0}'.format(platform.machine()))
print(Fore.BLUE +
      '[INFO]\t processor           : {0}'.format(platform.processor()))


# Overcommit
def check_overcommit_memory():
    overcommit_memory = int(get_value_proc('/proc/sys/vm/overcommit_memory'))
    if overcommit_memory != 2:
        print_report_bad(
            "Memory overcommitment is allowed on the system. This can lead to OOM Killer killing some PostgreSQL process, which will cause a PostgreSQL server restart (crash recovery)"
        )
        add_advice(
            'sysctl', 'urgent',
            'Try to echo vm.overcommit_memory=2 > /etc/sysctl.d/20-overcommit_memory.conf; sysctl -p - This will disable memory overcommitment and avoid postgresql killed by OOM killer.'
        )
        overcommit_ratio = int(get_value_proc('/proc/sys/vm/overcommit_ratio'))
        # print_report_info("sysctl vm.overcommit_ratio={0}".format(overcommit_ratio))
Beispiel #33
0
def on_powerpc():
    """ True if we are running on a Power PC platform."""
    return platform.processor() == 'powerpc' or \
           platform.machine().startswith('ppc')
Beispiel #34
0
    def set_properties(self):
        self._properties = SortedDict()
        if LSB:
            self.add_property(Property('is_lsb', _(u'LSB OS'), True))
            self.add_property(
                Property('distributor_id', _(u'Distributor ID'),
                         lsb_release('-i', '-s')))
            self.add_property(
                Property('description', _(u'Description'),
                         lsb_release('-d', '-s')))
            self.add_property(
                Property('release', _(u'Release'), lsb_release('-r', '-s')))
            self.add_property(
                Property('codename', _(u'Codename'), lsb_release('-c', '-s')))
            self.add_property(
                Property('sysinfo', _(u'System info'), uname('-a')))
        else:
            self.add_property(Property('is_posix', _(u'POSIX OS'), False))

        self.add_property(
            Property('architecture', _(u'OS architecture'),
                     platform.architecture()))
        self.add_property(
            Property('python_version', _(u'Python version'),
                     platform.python_version()))
        self.add_property(Property('hostname', _(u'Hostname'),
                                   platform.node()))
        self.add_property(Property('platform', _(u'Platform'), sys.platform))
        self.add_property(
            Property('machine', _(u'Machine'), platform.machine()))
        self.add_property(
            Property('processor', _(u'Processor'), platform.processor()))
        self.add_property(
            Property('cpus', _(u'Number of CPUs'), psutil.NUM_CPUS))
        self.add_property(
            Property('total_phymem', _(u'Total physical memory'),
                     pretty_size(psutil.TOTAL_PHYMEM)))
        self.add_property(
            Property(
                'disk_partitions', _(u'Disk partitions'), '; '.join([
                    '%s %s %s %s' % (partition.device, partition.mountpoint,
                                     partition.fstype, partition.opts)
                    for partition in psutil.disk_partitions()
                ])))

        try:
            self.add_property(
                Property('tesseract', _(u'tesseract version'),
                         pbs.tesseract('-v').stderr))
        except pbs.CommandNotFound:
            self.add_property(
                Property('tesseract', _(u'tesseract version'),
                         _(u'not found')))

        try:
            self.add_property(
                Property('unpaper', _(u'unpaper version'),
                         pbs.unpaper('-V').stdout))
        except pbs.CommandNotFound:
            self.add_property(
                Property('unpaper', _(u'unpaper version'), _(u'not found')))
Beispiel #35
0
import psutil
import platform

# задача 4  - вывести диагностическую информацию рабочей
# машины  - ЦПУ, оперативная память свободная/занятая,
# диски - свободно/занято, сетевые интерфейсы, тип и версия ОС

print(
    'CPU: {0}  CORES: {1} THREADS: {2} LOAD: {3} % FREQ_CUR: {4} MHz FREQ_MAX: {5} MHz FREQ_MIN: {6} MHz'
    .format(
        platform.processor(),  # Тип проца
        psutil.cpu_count(logical=False),  # Количество ядер
        psutil.cpu_count(),  # Ядра(логические)
        psutil.cpu_percent(interval=None),  # Нагрузка в данный момент
        int(psutil.cpu_freq()[0]),  # Частота в данный момент
        int(psutil.cpu_freq()[2]),  # Максимальная частота
        int(psutil.cpu_freq()[1]))  # Минимальная
)
print(
    'MEMORY ALL: {0} MB IN_USE: {1} MB FREE: {2} MB AVAILABLE: {3} MB'.format(
        int(psutil.virtual_memory().total / 1024 / 1024),  # Память вся
        int(psutil.virtual_memory().used / 1024 / 1024),  # Использованная
        int(psutil.virtual_memory().free / 1024 / 1024),  # Свободная
        int(psutil.virtual_memory().available / 1024 /
            1024))  # Всего доступно памяти
)
print('DISKS: ')
for part in psutil.disk_partitions():
    print(
        '     DEV :{0:<15} MOUNT: {1:<30} fstype: {2:<10} USED: {3:<10}  FREE: {4:<10} MB ALL: {5} MB'
        .format(
Beispiel #36
0
# Starting system analysis
print "[!] ", "Checking your system *wait...\n\n"
now = datetime.now()
print "[-] Checking Start time is.. : ", now, "\n"

#import your system name and network ip addr
f0x_name = socket.gethostname()
f0x_ip = socket.gethostbyname(f0x_name)
print "컴퓨터 이름 : ", f0x_name
print "컴퓨터 Ip addr :", f0x_ip, "\n"

print "[+] ", "OS 종류: ", platform.system()
print "[+] ", "OS 상세정보: ", platform.platform()
print "[+] ", "OS 버전: ", platform.version()
print "[+] ", "프로세서: ", platform.processor()
print "[+] ", "CPU 수: ", multiprocessing.cpu_count(), "\n\n"


def initialize_openhardwaremonitor():
    file = 'OpenHardwareMonitorLib.dll'
    clr.AddReference(file)

    from OpenHardwareMonitor import Hardware

    handle = Hardware.Computer()
    handle.MainboardEnabled = True
    handle.CPUEnabled = True
    handle.RAMEnabled = True
    handle.GPUEnabled = True
    handle.HDDEnabled = True
Beispiel #37
0
def checkproc():
    ans = str(platform.processor())
    return ans
Beispiel #38
0
    def __init__(self):

        self.msg = lcg.msg.msg('LCG Configuration')

        # check operating system
        # variables in this section
        self.isWin32 = 0
        self.isMacOS = 0
        self.isLinux = 0

        # checks
        if sys.platform in [
                'darwin',
        ]: self.isMacOS = 1
        elif sys.platform in [
                'linux',
                'linux2',
        ]: self.isLinux = 1
        elif sys.platform in [
                'win32',
        ]: self.isWin32 = 1

        # set lib path name
        self.libpathname = ''
        if self.isMacOS: self.libpathname = 'DYLD_LIBRARY_PATH'
        elif self.isLinux: self.libpathname = 'LD_LIBRARY_PATH'
        elif self.isWin32: self.libpathname = 'PATH'

        # check processor type
        self.processor = ''
        self.architecture = ''

        # checks
        self.processor = platform.processor()
        self.architecture = platform.architecture()

        # check architecture
        self.is32bit = 0
        self.is64bit = 0

        if platform.architecture()[0] == '32bit': self.is32bit = 1
        if platform.architecture()[0] == '64bit': self.is64bit = 1

        # check processor endianess
        # variables in this section
        self.isBigEndian = 0
        self.isLittleEndian = 0

        # checks
        if sys.byteorder == 'big': self.isBigEndian = 1
        elif sys.byteorder == 'little': self.isLittleEndian = 1

        # check operating system version
        # variables in this section
        self.osMaxRelease = 0
        self.osMajRelease = 0
        self.osMinRelease = 0
        self.osReleaseStr = ''

        # checks
        if self.isMacOS:
            verList = map(lambda x: int(x), platform.release().split('.'))
            if len(verList) > 2:

                self.osMaxRelease = 10
                self.osMajRelease = verList[0] - 4
                self.osMinRelease = verList[1]

                if self.osMaxRelease == 10:
                    if self.osMajRelease == 3: self.osReleaseStr = 'Panther'
                    elif self.osMajRelease == 4: self.osReleaseStr = 'Tiger'
                    elif self.osMajRelease == 5: self.osReleaseStr = 'Leopard'
                    elif self.osMajRelease == 6:
                        self.osReleaseStr = 'Snow Leopard'
                    else:
                        self.msg.error(
                            'Second number of os release no %s unknown' %
                            verList)
                else:
                    self.msg.error('First number of os release no %s unknown' %
                                   verList)
            else:
                self.msg.error(
                    'Trouble reading os relase, expected a list of min len 3, got'
                    % verList)

        elif self.isLinux:

            if os.path.isfile('/etc/issue'):
                issue = open('/etc/issue', 'r')
                firstl = issue.readline().split()
                if ' '.join(firstl[:5]) == 'Scientific Linux CERN SLC release':
                    self.osReleaseStr = 'slc' + firstl[5].split('.')[0]
                    self.osMaxRelease = firstl[5].split('.')[0]
                    self.osMajRelease = firstl[5].split('.')[1]
                issue.close()

        elif self.isWin32:

            pass

        # check afs availability
        # variables in this section
        self.hasAFS = 0
        self.p_afs = ''

        if 1:  # check afs availability

            if self.isWin32:

                if os.environ().has_key('AFS'):

                    self.p_afs = os.environ()['AFS']
                    self.msg.info(
                        'Found environment variable AFS, setting self.p_afs to %s'
                        % self.p_afs)

                else:

                    self.p_afs = 'E:'
                    self.msg.warning(
                        'No environment variable AFS found, setting self.p_afs to %s'
                        % self.p_afs)
Beispiel #39
0
    def build_extensions(self):

        library_dirs = []
        include_dirs = []

        _add_directory(include_dirs, "src/libImaging")

        pkg_config = None
        if _cmd_exists('pkg-config'):
            pkg_config = _pkg_config

        #
        # add configured kits
        for root_name, lib_name in dict(
                JPEG_ROOT="libjpeg",
                JPEG2K_ROOT="libopenjp2",
                TIFF_ROOT=("libtiff-5", "libtiff-4"),
                ZLIB_ROOT="zlib",
                FREETYPE_ROOT="freetype2",
                LCMS_ROOT="lcms2",
                IMAGEQUANT_ROOT="libimagequant").items():
            root = globals()[root_name]
            if root is None and pkg_config:
                if isinstance(lib_name, tuple):
                    for lib_name2 in lib_name:
                        _dbg('Looking for `%s` using pkg-config.' % lib_name2)
                        root = pkg_config(lib_name2)
                        if root:
                            break
                else:
                    _dbg('Looking for `%s` using pkg-config.' % lib_name)
                    root = pkg_config(lib_name)

            if isinstance(root, tuple):
                lib_root, include_root = root
            else:
                lib_root = include_root = root

            _add_directory(library_dirs, lib_root)
            _add_directory(include_dirs, include_root)

        # respect CFLAGS/LDFLAGS
        for k in ('CFLAGS', 'LDFLAGS'):
            if k in os.environ:
                for match in re.finditer(r'-I([^\s]+)', os.environ[k]):
                    _add_directory(include_dirs, match.group(1))
                for match in re.finditer(r'-L([^\s]+)', os.environ[k]):
                    _add_directory(library_dirs, match.group(1))

        # include, rpath, if set as environment variables:
        for k in ('C_INCLUDE_PATH', 'CPATH', 'INCLUDE'):
            if k in os.environ:
                for d in os.environ[k].split(os.path.pathsep):
                    _add_directory(include_dirs, d)

        for k in ('LD_RUN_PATH', 'LIBRARY_PATH', 'LIB'):
            if k in os.environ:
                for d in os.environ[k].split(os.path.pathsep):
                    _add_directory(library_dirs, d)

        prefix = sysconfig.get_config_var("prefix")
        if prefix:
            _add_directory(library_dirs, os.path.join(prefix, "lib"))
            _add_directory(include_dirs, os.path.join(prefix, "include"))

        #
        # add platform directories

        if self.disable_platform_guessing:
            pass

        elif sys.platform == "cygwin":
            # pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory
            _add_directory(
                library_dirs,
                os.path.join("/usr/lib", "python%s" % sys.version[:3],
                             "config"))

        elif sys.platform == "darwin":
            # attempt to make sure we pick freetype2 over other versions
            _add_directory(include_dirs, "/sw/include/freetype2")
            _add_directory(include_dirs, "/sw/lib/freetype2/include")
            # fink installation directories
            _add_directory(library_dirs, "/sw/lib")
            _add_directory(include_dirs, "/sw/include")
            # darwin ports installation directories
            _add_directory(library_dirs, "/opt/local/lib")
            _add_directory(include_dirs, "/opt/local/include")

            # if Homebrew is installed, use its lib and include directories
            try:
                prefix = subprocess.check_output(['brew', '--prefix'
                                                  ]).strip().decode('latin1')
            except Exception:
                # Homebrew not installed
                prefix = None

            ft_prefix = None

            if prefix:
                # add Homebrew's include and lib directories
                _add_directory(library_dirs, os.path.join(prefix, 'lib'))
                _add_directory(include_dirs, os.path.join(prefix, 'include'))
                ft_prefix = os.path.join(prefix, 'opt', 'freetype')

            if ft_prefix and os.path.isdir(ft_prefix):
                # freetype might not be linked into Homebrew's prefix
                _add_directory(library_dirs, os.path.join(ft_prefix, 'lib'))
                _add_directory(include_dirs,
                               os.path.join(ft_prefix, 'include'))
            else:
                # fall back to freetype from XQuartz if
                # Homebrew's freetype is missing
                _add_directory(library_dirs, "/usr/X11/lib")
                _add_directory(include_dirs, "/usr/X11/include")

        elif sys.platform.startswith("linux"):
            arch_tp = (plat.processor(), plat.architecture()[0])
            # This should be correct on debian derivatives.
            if os.path.exists('/etc/debian_version'):
                # If this doesn't work, don't just silently patch
                # downstream because it's going to break when people
                # try to build pillow from source instead of
                # installing from the system packages.
                self.add_multiarch_paths()

            elif arch_tp == ("x86_64", "32bit"):
                # Special Case: 32-bit build on 64-bit machine.
                _add_directory(library_dirs, "/usr/lib/i386-linux-gnu")
            else:
                libdirs = {
                    'x86_64':
                    ["/lib64", "/usr/lib64", "/usr/lib/x86_64-linux-gnu"],
                    '64bit':
                    ["/lib64", "/usr/lib64", "/usr/lib/x86_64-linux-gnu"],
                    'i386': ["/usr/lib/i386-linux-gnu"],
                    'i686': ["/usr/lib/i386-linux-gnu"],
                    '32bit': ["/usr/lib/i386-linux-gnu"],
                    'aarch64': ["/usr/lib64", "/usr/lib/aarch64-linux-gnu"],
                    'arm': ["/usr/lib/arm-linux-gnueabi"],
                    'armv71': ["/usr/lib/arm-linux-gnueabi"],
                    'armv7l': ["/usr/lib"],
                    'ppc64': [
                        "/usr/lib64", "/usr/lib/ppc64-linux-gnu",
                        "/usr/lib/powerpc64-linux-gnu"
                    ],
                    'ppc64le': ["/usr/lib64"],
                    'ppc':
                    ["/usr/lib/ppc-linux-gnu", "/usr/lib/powerpc-linux-gnu"],
                    's390x': ["/usr/lib64", "/usr/lib/s390x-linux-gnu"],
                    's390': ["/usr/lib/s390-linux-gnu"],
                }

                for platform_ in arch_tp:
                    dirs = libdirs.get(platform_, None)
                    if not dirs:
                        continue
                    for path in dirs:
                        _add_directory(library_dirs, path)
                    break

                else:
                    raise ValueError(
                        "Unable to identify Linux platform: `%s`" % platform_)

                # termux support for android.
                # system libraries (zlib) are installed in /system/lib
                # headers are at $PREFIX/include
                # user libs are at $PREFIX/lib
                if os.environ.get('ANDROID_ROOT', None):
                    _add_directory(
                        library_dirs,
                        os.path.join(os.environ['ANDROID_ROOT'], 'lib'))

        elif sys.platform.startswith("gnu"):
            self.add_multiarch_paths()

        elif sys.platform.startswith("freebsd"):
            _add_directory(library_dirs, "/usr/local/lib")
            _add_directory(include_dirs, "/usr/local/include")

        elif sys.platform.startswith("netbsd"):
            _add_directory(library_dirs, "/usr/pkg/lib")
            _add_directory(include_dirs, "/usr/pkg/include")

        elif sys.platform.startswith("sunos5"):
            _add_directory(library_dirs, "/opt/local/lib")
            _add_directory(include_dirs, "/opt/local/include")

        # FIXME: check /opt/stuff directories here?

        # standard locations
        if not self.disable_platform_guessing:
            _add_directory(library_dirs, "/usr/local/lib")
            _add_directory(include_dirs, "/usr/local/include")

            _add_directory(library_dirs, "/usr/lib")
            _add_directory(include_dirs, "/usr/include")
            # alpine, at least
            _add_directory(library_dirs, "/lib")

        # on Windows, look for the OpenJPEG libraries in the location that
        # the official installer puts them
        if sys.platform == "win32":
            program_files = os.environ.get('ProgramFiles', '')
            best_version = (0, 0)
            best_path = None
            for name in os.listdir(program_files):
                if name.startswith('OpenJPEG '):
                    version = tuple(
                        int(x) for x in name[9:].strip().split('.'))
                    if version > best_version:
                        best_version = version
                        best_path = os.path.join(program_files, name)

            if best_path:
                _dbg('Adding %s to search list', best_path)
                _add_directory(library_dirs, os.path.join(best_path, 'lib'))
                _add_directory(include_dirs,
                               os.path.join(best_path, 'include'))

        #
        # insert new dirs *before* default libs, to avoid conflicts
        # between Python PYD stub libs and real libraries

        self.compiler.library_dirs = library_dirs + self.compiler.library_dirs
        self.compiler.include_dirs = include_dirs + self.compiler.include_dirs

        #
        # look for available libraries

        feature = self.feature

        if feature.want('zlib'):
            _dbg('Looking for zlib')
            if _find_include_file(self, "zlib.h"):
                if _find_library_file(self, "z"):
                    feature.zlib = "z"
                elif (sys.platform == "win32"
                      and _find_library_file(self, "zlib")):
                    feature.zlib = "zlib"  # alternative name

        if feature.want('jpeg'):
            _dbg('Looking for jpeg')
            if _find_include_file(self, "jpeglib.h"):
                if _find_library_file(self, "jpeg"):
                    feature.jpeg = "jpeg"
                elif (sys.platform == "win32"
                      and _find_library_file(self, "libjpeg")):
                    feature.jpeg = "libjpeg"  # alternative name

        feature.openjpeg_version = None
        if feature.want('jpeg2000'):
            _dbg('Looking for jpeg2000')
            best_version = None
            best_path = None

            # Find the best version
            for directory in self.compiler.include_dirs:
                _dbg('Checking for openjpeg-#.# in %s', directory)
                try:
                    listdir = os.listdir(directory)
                except Exception:
                    # WindowsError, FileNotFoundError
                    continue
                for name in listdir:
                    if name.startswith('openjpeg-') and \
                        os.path.isfile(os.path.join(directory, name,
                                                    'openjpeg.h')):
                        _dbg('Found openjpeg.h in %s/%s', (directory, name))
                        version = tuple(int(x) for x in name[9:].split('.'))
                        if best_version is None or version > best_version:
                            best_version = version
                            best_path = os.path.join(directory, name)
                            _dbg('Best openjpeg version %s so far in %s',
                                 (best_version, best_path))

            if best_version and _find_library_file(self, 'openjp2'):
                # Add the directory to the include path so we can include
                # <openjpeg.h> rather than having to cope with the versioned
                # include path
                # FIXME (melvyn-sopacua):
                # At this point it's possible that best_path is already in
                # self.compiler.include_dirs. Should investigate how that is
                # possible.
                _add_directory(self.compiler.include_dirs, best_path, 0)
                feature.jpeg2000 = 'openjp2'
                feature.openjpeg_version = '.'.join(
                    str(x) for x in best_version)

        if feature.want('imagequant'):
            _dbg('Looking for imagequant')
            if _find_include_file(self, 'libimagequant.h'):
                if _find_library_file(self, "imagequant"):
                    feature.imagequant = "imagequant"
                elif _find_library_file(self, "libimagequant"):
                    feature.imagequant = "libimagequant"

        if feature.want('tiff'):
            _dbg('Looking for tiff')
            if _find_include_file(self, 'tiff.h'):
                if _find_library_file(self, "tiff"):
                    feature.tiff = "tiff"
                if sys.platform == "win32" and _find_library_file(
                        self, "libtiff"):
                    feature.tiff = "libtiff"
                if (sys.platform == "darwin"
                        and _find_library_file(self, "libtiff")):
                    feature.tiff = "libtiff"

        if feature.want('freetype'):
            _dbg('Looking for freetype')
            if _find_library_file(self, "freetype"):
                # look for freetype2 include files
                freetype_version = 0
                for subdir in self.compiler.include_dirs:
                    _dbg('Checking for include file %s in %s',
                         ("ft2build.h", subdir))
                    if os.path.isfile(os.path.join(subdir, "ft2build.h")):
                        _dbg('Found %s in %s', ("ft2build.h", subdir))
                        freetype_version = 21
                        subdir = os.path.join(subdir, "freetype2")
                        break
                    subdir = os.path.join(subdir, "freetype2")
                    _dbg('Checking for include file %s in %s',
                         ("ft2build.h", subdir))
                    if os.path.isfile(os.path.join(subdir, "ft2build.h")):
                        _dbg('Found %s in %s', ("ft2build.h", subdir))
                        freetype_version = 21
                        break
                if freetype_version:
                    feature.freetype = "freetype"
                    feature.freetype_version = freetype_version
                    if subdir:
                        _add_directory(self.compiler.include_dirs, subdir, 0)

        if feature.want('lcms'):
            _dbg('Looking for lcms')
            if _find_include_file(self, "lcms2.h"):
                if _find_library_file(self, "lcms2"):
                    feature.lcms = "lcms2"
                elif _find_library_file(self, "lcms2_static"):
                    # alternate Windows name.
                    feature.lcms = "lcms2_static"

        if feature.want('webp'):
            _dbg('Looking for webp')
            if (_find_include_file(self, "webp/encode.h")
                    and _find_include_file(self, "webp/decode.h")):
                # In Google's precompiled zip it is call "libwebp":
                if _find_library_file(self, "webp"):
                    feature.webp = "webp"
                elif _find_library_file(self, "libwebp"):
                    feature.webp = "libwebp"

        if feature.want('webpmux'):
            _dbg('Looking for webpmux')
            if (_find_include_file(self, "webp/mux.h")
                    and _find_include_file(self, "webp/demux.h")):
                if (_find_library_file(self, "webpmux")
                        and _find_library_file(self, "webpdemux")):
                    feature.webpmux = "webpmux"
                if (_find_library_file(self, "libwebpmux")
                        and _find_library_file(self, "libwebpdemux")):
                    feature.webpmux = "libwebpmux"

        for f in feature:
            if not getattr(feature, f) and feature.require(f):
                if f in ('jpeg', 'zlib'):
                    raise RequiredDependencyException(f)
                raise DependencyException(f)

        #
        # core library

        files = ["src/_imaging.c"]
        for src_file in _IMAGING:
            files.append("src/" + src_file + ".c")
        for src_file in _LIB_IMAGING:
            files.append(os.path.join("src/libImaging", src_file + ".c"))

        libs = []
        defs = []
        if feature.jpeg:
            libs.append(feature.jpeg)
            defs.append(("HAVE_LIBJPEG", None))
        if feature.jpeg2000:
            libs.append(feature.jpeg2000)
            defs.append(("HAVE_OPENJPEG", None))
            if sys.platform == "win32":
                defs.append(("OPJ_STATIC", None))
        if feature.zlib:
            libs.append(feature.zlib)
            defs.append(("HAVE_LIBZ", None))
        if feature.imagequant:
            libs.append(feature.imagequant)
            defs.append(("HAVE_LIBIMAGEQUANT", None))
        if feature.tiff:
            libs.append(feature.tiff)
            defs.append(("HAVE_LIBTIFF", None))
        if sys.platform == "win32":
            libs.extend(["kernel32", "user32", "gdi32"])
        if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1:
            defs.append(("WORDS_BIGENDIAN", None))

        if sys.platform == "win32" and not (PLATFORM_PYPY or PLATFORM_MINGW):
            defs.append(("PILLOW_VERSION", '"\\"%s\\""' % PILLOW_VERSION))
        else:
            defs.append(("PILLOW_VERSION", '"%s"' % PILLOW_VERSION))

        exts = [(Extension("PIL._imaging",
                           files,
                           libraries=libs,
                           define_macros=defs))]

        #
        # additional libraries

        if feature.freetype:
            libs = ["freetype"]
            defs = []
            exts.append(
                Extension("PIL._imagingft", ["src/_imagingft.c"],
                          libraries=libs,
                          define_macros=defs))

        if feature.lcms:
            extra = []
            if sys.platform == "win32":
                extra.extend(["user32", "gdi32"])
            exts.append(
                Extension("PIL._imagingcms", ["src/_imagingcms.c"],
                          libraries=[feature.lcms] + extra))

        if feature.webp:
            libs = [feature.webp]
            defs = []

            if feature.webpmux:
                defs.append(("HAVE_WEBPMUX", None))
                libs.append(feature.webpmux)
                libs.append(feature.webpmux.replace('pmux', 'pdemux'))

            exts.append(
                Extension("PIL._webp", ["src/_webp.c"],
                          libraries=libs,
                          define_macros=defs))

        tk_libs = ['psapi'] if sys.platform == 'win32' else []
        exts.append(
            Extension("PIL._imagingtk",
                      ["src/_imagingtk.c", "src/Tk/tkImaging.c"],
                      include_dirs=['src/Tk'],
                      libraries=tk_libs))

        exts.append(Extension("PIL._imagingmath", ["src/_imagingmath.c"]))
        exts.append(Extension("PIL._imagingmorph", ["src/_imagingmorph.c"]))

        self.extensions[:] = exts

        build_ext.build_extensions(self)

        #
        # sanity checks

        self.summary_report(feature)
Beispiel #40
0
class Hpl(AutotoolsPackage):
    """HPL is a software package that solves a (random) dense linear system
    in double precision (64 bits) arithmetic on distributed-memory computers.
    It can thus be regarded as a portable as well as freely available
    implementation of the High Performance Computing Linpack Benchmark."""

    homepage = "https://www.netlib.org/benchmark/hpl/"
    url = "https://www.netlib.org/benchmark/hpl/hpl-2.2.tar.gz"

    # Note: HPL uses autotools starting with 2.3

    version('2.3',
            sha256=
            '32c5c17d22330e6f2337b681aded51637fb6008d3f0eb7c277b163fadd612830')
    version('2.2',
            sha256=
            'ac7534163a09e21a5fa763e4e16dfc119bc84043f6e6a807aba666518f8df440')

    variant('openmp', default=False, description='Enable OpenMP support')

    depends_on('[email protected]:')
    depends_on('blas')

    # 2.3 adds support for openmpi 4
    conflicts('^[email protected]:', when='@:2.2')

    parallel = False

    arch = '{0}-{1}'.format(platform.system(), platform.processor())
    build_targets = ['arch={0}'.format(arch)]

    @when('@:2.2')
    def autoreconf(self, spec, prefix):
        # Prevent sanity check from killing the build
        touch('configure')

    @when('@:2.2')
    def configure(self, spec, prefix):
        # List of configuration options
        # Order is important
        config = []

        # OpenMP support
        if '+openmp' in spec:
            config.append('OMP_DEFS     = {0}'.format(
                self.compiler.openmp_flag))

        config.extend([
            # Shell
            'SHELL        = /bin/sh',
            'CD           = cd',
            'CP           = cp',
            'LN_S         = ln -fs',
            'MKDIR        = mkdir -p',
            'RM           = /bin/rm -f',
            'TOUCH        = touch',
            # Platform identifier
            'ARCH         = {0}'.format(self.arch),
            # HPL Directory Structure / HPL library
            'TOPdir       = {0}'.format(os.getcwd()),
            'INCdir       = $(TOPdir)/include',
            'BINdir       = $(TOPdir)/bin/$(ARCH)',
            'LIBdir       = $(TOPdir)/lib/$(ARCH)',
            'HPLlib       = $(LIBdir)/libhpl.a',
            # Message Passing library (MPI)
            'MPinc        = {0}'.format(spec['mpi'].prefix.include),
            'MPlib        = -L{0}'.format(spec['mpi'].prefix.lib),
            # Linear Algebra library (BLAS or VSIPL)
            'LAinc        = {0}'.format(spec['blas'].prefix.include),
            'LAlib        = {0}'.format(spec['blas'].libs.joined()),
            # F77 / C interface
            'F2CDEFS      = -DAdd_ -DF77_INTEGER=int -DStringSunStyle',
            # HPL includes / libraries / specifics
            'HPL_INCLUDES = -I$(INCdir) -I$(INCdir)/$(ARCH) ' +
            '-I$(LAinc) -I$(MPinc)',
            'HPL_LIBS     = $(HPLlib) $(LAlib) $(MPlib)',
            'HPL_OPTS     = -DHPL_DETAILED_TIMING -DHPL_PROGRESS_REPORT',
            'HPL_DEFS     = $(F2CDEFS) $(HPL_OPTS) $(HPL_INCLUDES)',
            # Compilers / linkers - Optimization flags
            'CC           = {0}'.format(spec['mpi'].mpicc),
            'CCNOOPT      = $(HPL_DEFS)',
            'CCFLAGS      = $(HPL_DEFS) -O3',
            'LINKER       = $(CC)',
            'LINKFLAGS    = $(CCFLAGS) $(OMP_DEFS)',
            'ARCHIVER     = ar',
            'ARFLAGS      = r',
            'RANLIB       = echo'
        ])

        # Write configuration options to include file
        with open('Make.{0}'.format(self.arch), 'w') as makefile:
            for var in config:
                makefile.write('{0}\n'.format(var))

    @when('@2.3:')
    def configure_args(self):
        filter_file(r"^libs10=.*",
                    "libs10=%s" % self.spec["blas"].libs.ld_flags, "configure")

        if '+openmp' in self.spec:
            config = ['CFLAGS=-O3 ' + self.compiler.openmp_flag]
        else:
            config = ['CFLAGS=-O3']

        if (self.spec.satisfies('^intel-mkl')
                or self.spec.satisfies('^intel-oneapi-mkl')
                or self.spec.satisfies('^intel-parallel-studio+mkl')):
            config.append('LDFLAGS={0}'.format(
                self.spec['blas'].libs.ld_flags))

        return config

    @when('@:2.2')
    def install(self, spec, prefix):
        # Manual installation
        install_tree(join_path('bin', self.arch), prefix.bin)
        install_tree(join_path('lib', self.arch), prefix.lib)
        install_tree(join_path('include', self.arch), prefix.include)
        install_tree('man', prefix.man)

    @run_after('install')
    def copy_dat(self):
        if self.spec.satisfies('@2.3:'):
            # The pre-2.3 makefile would include a default HPL.dat config
            # file in the bin directory
            install('./testing/ptest/HPL.dat',
                    join_path(self.prefix.bin, 'HPL.dat'))
Beispiel #41
0
    def build_extensions(self):

        global TCL_ROOT

        library_dirs = []
        include_dirs = []

        _add_directory(include_dirs, "libImaging")

        #
        # add configured kits

        for root in (TCL_ROOT, JPEG_ROOT, TIFF_ROOT, ZLIB_ROOT, FREETYPE_ROOT,
                     LCMS_ROOT):
            if isinstance(root, type(())):
                lib_root, include_root = root
            else:
                lib_root = include_root = root
            _add_directory(library_dirs, lib_root)
            _add_directory(include_dirs, include_root)

        #
        # add platform directories

        if sys.platform == "cygwin":
            # pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory
            _add_directory(
                library_dirs,
                os.path.join("/usr/lib", "python%s" % sys.version[:3],
                             "config"))

        elif sys.platform == "darwin":
            # attempt to make sure we pick freetype2 over other versions
            _add_directory(include_dirs, "/sw/include/freetype2")
            _add_directory(include_dirs, "/sw/lib/freetype2/include")
            # fink installation directories
            _add_directory(library_dirs, "/sw/lib")
            _add_directory(include_dirs, "/sw/include")
            # darwin ports installation directories
            _add_directory(library_dirs, "/opt/local/lib")
            _add_directory(include_dirs, "/opt/local/include")
            # freetype2 ships with X11
            _add_directory(library_dirs, "/usr/X11/lib")
            _add_directory(include_dirs, "/usr/X11/include")

        elif sys.platform.startswith("linux"):
            for platform_ in (plat.processor(), plat.architecture()[0]):

                if not platform_:
                    continue

                if platform_ in ["x86_64", "64bit"]:
                    _add_directory(library_dirs, "/lib64")
                    _add_directory(library_dirs, "/usr/lib64")
                    _add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")
                    break
                elif platform_ in ["i386", "i686", "32bit"]:
                    _add_directory(library_dirs, "/usr/lib/i386-linux-gnu")
                    break
            else:
                raise ValueError("Unable to identify Linux platform: `%s`" %
                                 platform_)

            # XXX Kludge. Above /\ we brute force support multiarch. Here we
            # try Barry's more general approach. Afterward, something should
            # work ;-)
            self.add_multiarch_paths()

        _add_directory(library_dirs, "/usr/local/lib")
        # FIXME: check /opt/stuff directories here?

        # include, rpath, if set as environment variables:
        if os.environ.get('C_INCLUDE_PATH'):
            _add_directory(include_dirs, os.environ.get('C_INCLUDE_PATH'))
        if os.environ.get('LD_RUN_PATH'):
            _add_directory(library_dirs, os.environ.get('LD_RUN_PATH'))

        prefix = sysconfig.get_config_var("prefix")
        if prefix:
            _add_directory(library_dirs, os.path.join(prefix, "lib"))
            _add_directory(include_dirs, os.path.join(prefix, "include"))

        #
        # locate tkinter libraries

        if _tkinter:
            TCL_VERSION = _tkinter.TCL_VERSION[:3]

        if _tkinter and not TCL_ROOT:
            # we have Tkinter but the TCL_ROOT variable was not set;
            # try to locate appropriate Tcl/Tk libraries
            PYVERSION = sys.version[0] + sys.version[2]
            TCLVERSION = TCL_VERSION[0] + TCL_VERSION[2]
            roots = [
                # common installation directories, mostly for Windows
                # (for Unix-style platforms, we'll check in well-known
                # locations later)
                os.path.join("/py" + PYVERSION, "Tcl"),
                os.path.join("/python" + PYVERSION, "Tcl"),
                "/Tcl",
                "/Tcl" + TCLVERSION,
                "/Tcl" + TCL_VERSION,
                os.path.join(os.environ.get("ProgramFiles", ""), "Tcl"),
            ]
            for TCL_ROOT in roots:
                TCL_ROOT = os.path.abspath(TCL_ROOT)
                if os.path.isfile(os.path.join(TCL_ROOT, "include", "tk.h")):
                    # FIXME: use distutils logging (?)
                    print("--- using Tcl/Tk libraries at", TCL_ROOT)
                    print("--- using Tcl/Tk version", TCL_VERSION)
                    TCL_ROOT = _lib_include(TCL_ROOT)
                    break
            else:
                TCL_ROOT = None

        # add standard directories

        # look for tcl specific subdirectory (e.g debian)
        if _tkinter:
            tcl_dir = "/usr/include/tcl" + TCL_VERSION
            if os.path.isfile(os.path.join(tcl_dir, "tk.h")):
                _add_directory(include_dirs, tcl_dir)

        # standard locations
        _add_directory(library_dirs, "/usr/local/lib")
        _add_directory(include_dirs, "/usr/local/include")

        _add_directory(library_dirs, "/usr/lib")
        _add_directory(include_dirs, "/usr/include")

        #
        # insert new dirs *before* default libs, to avoid conflicts
        # between Python PYD stub libs and real libraries

        self.compiler.library_dirs = library_dirs + self.compiler.library_dirs
        self.compiler.include_dirs = include_dirs + self.compiler.include_dirs

        #
        # look for available libraries

        feature = self.feature

        if feature.want('zlib'):
            if _find_include_file(self, "zlib.h"):
                if _find_library_file(self, "z"):
                    feature.zlib = "z"
                elif sys.platform == "win32" and _find_library_file(
                        self, "zlib"):
                    feature.zlib = "zlib"  # alternative name

        if feature.want('jpeg'):
            if _find_include_file(self, "jpeglib.h"):
                if _find_library_file(self, "jpeg"):
                    feature.jpeg = "jpeg"
                elif (sys.platform == "win32"
                      and _find_library_file(self, "libjpeg")):
                    feature.jpeg = "libjpeg"  # alternative name

        if feature.want('tiff'):
            if _find_library_file(self, "tiff"):
                feature.tiff = "tiff"
            if sys.platform == "win32" and _find_library_file(self, "libtiff"):
                feature.tiff = "libtiff"
            if sys.platform == "darwin" and _find_library_file(
                    self, "libtiff"):
                feature.tiff = "libtiff"

        if feature.want('freetype'):
            if _find_library_file(self, "freetype"):
                # look for freetype2 include files
                freetype_version = 0
                for dir in self.compiler.include_dirs:
                    if os.path.isfile(os.path.join(dir, "ft2build.h")):
                        freetype_version = 21
                        dir = os.path.join(dir, "freetype2")
                        break
                    dir = os.path.join(dir, "freetype2")
                    if os.path.isfile(os.path.join(dir, "ft2build.h")):
                        freetype_version = 21
                        break
                    if os.path.isdir(os.path.join(dir, "freetype")):
                        freetype_version = 20
                        break
                if freetype_version:
                    feature.freetype = "freetype"
                    feature.freetype_version = freetype_version
                    if dir:
                        _add_directory(self.compiler.include_dirs, dir, 0)

        if feature.want('lcms'):
            if _find_include_file(self, "lcms.h"):
                if _find_library_file(self, "lcms"):
                    feature.lcms = "lcms"

        if _tkinter and _find_include_file(self, "tk.h"):
            # the library names may vary somewhat (e.g. tcl84 or tcl8.4)
            version = TCL_VERSION[0] + TCL_VERSION[2]
            if feature.want('tcl'):
                if _find_library_file(self, "tcl" + version):
                    feature.tcl = "tcl" + version
                elif _find_library_file(self, "tcl" + TCL_VERSION):
                    feature.tcl = "tcl" + TCL_VERSION
            if feature.want('tk'):
                if _find_library_file(self, "tk" + version):
                    feature.tk = "tk" + version
                elif _find_library_file(self, "tk" + TCL_VERSION):
                    feature.tk = "tk" + TCL_VERSION

        if feature.want('webp'):
            if (_find_include_file(self, "webp/encode.h")
                    and _find_include_file(self, "webp/decode.h")):
                if _find_library_file(
                        self, "webp"
                ):  # in googles precompiled zip it is call "libwebp"
                    feature.webp = "webp"

        if feature.want('webpmux'):
            if (_find_include_file(self, "webp/mux.h")
                    and _find_include_file(self, "webp/demux.h")):
                if _find_library_file(self, "webpmux") and _find_library_file(
                        self, "webpdemux"):
                    feature.webpmux = "webpmux"

        for f in feature:
            if not getattr(feature, f) and feature.require(f):
                raise ValueError(
                    '--enable-%s requested but %s not found, aborting.' %
                    (f, f))

        #
        # core library

        files = ["_imaging.c"]
        for file in _IMAGING:
            files.append(file + ".c")
        for file in _LIB_IMAGING:
            files.append(os.path.join("libImaging", file + ".c"))

        libs = []
        defs = []
        if feature.jpeg:
            libs.append(feature.jpeg)
            defs.append(("HAVE_LIBJPEG", None))
        if feature.zlib:
            libs.append(feature.zlib)
            defs.append(("HAVE_LIBZ", None))
        if feature.tiff:
            libs.append(feature.tiff)
            defs.append(("HAVE_LIBTIFF", None))
        if sys.platform == "win32":
            libs.extend(["kernel32", "user32", "gdi32"])
        if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1:
            defs.append(("WORDS_BIGENDIAN", None))

        exts = [(Extension("PIL._imaging",
                           files,
                           libraries=libs,
                           define_macros=defs))]

        #
        # additional libraries

        if feature.freetype:
            defs = []
            if feature.freetype_version == 20:
                defs.append(("USE_FREETYPE_2_0", None))
            exts.append(
                Extension("PIL._imagingft", ["_imagingft.c"],
                          libraries=["freetype"],
                          define_macros=defs))

        if os.path.isfile("_imagingtiff.c") and feature.tiff:
            exts.append(
                Extension("PIL._imagingtiff", ["_imagingtiff.c"],
                          libraries=["tiff"]))

        if os.path.isfile("_imagingcms.c") and feature.lcms:
            extra = []
            if sys.platform == "win32":
                extra.extend(["user32", "gdi32"])
            exts.append(
                Extension("PIL._imagingcms", ["_imagingcms.c"],
                          libraries=["lcms"] + extra))

        if os.path.isfile("_webp.c") and feature.webp:
            libs = ["webp"]
            defs = []

            if feature.webpmux:
                defs.append(("HAVE_WEBPMUX", None))
                libs.append("webpmux")
                libs.append("webpdemux")

            exts.append(
                Extension("PIL._webp", ["_webp.c"],
                          libraries=libs,
                          define_macros=defs))

        if sys.platform == "darwin":
            # locate Tcl/Tk frameworks
            frameworks = []
            framework_roots = [
                "/Library/Frameworks", "/System/Library/Frameworks"
            ]
            for root in framework_roots:
                if (os.path.exists(os.path.join(root, "Tcl.framework")) and
                        os.path.exists(os.path.join(root, "Tk.framework"))):
                    print("--- using frameworks at %s" % root)
                    frameworks = ["-framework", "Tcl", "-framework", "Tk"]
                    dir = os.path.join(root, "Tcl.framework", "Headers")
                    _add_directory(self.compiler.include_dirs, dir, 0)
                    dir = os.path.join(root, "Tk.framework", "Headers")
                    _add_directory(self.compiler.include_dirs, dir, 1)
                    break
            if frameworks:
                exts.append(
                    Extension("PIL._imagingtk",
                              ["_imagingtk.c", "Tk/tkImaging.c"],
                              extra_compile_args=frameworks,
                              extra_link_args=frameworks))
                feature.tcl = feature.tk = 1  # mark as present
        elif feature.tcl and feature.tk:
            exts.append(
                Extension("PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
                          libraries=[feature.tcl, feature.tk]))

        if os.path.isfile("_imagingmath.c"):
            exts.append(Extension("PIL._imagingmath", ["_imagingmath.c"]))

        self.extensions[:] = exts

        build_ext.build_extensions(self)

        #
        # sanity and security checks

        unsafe_zlib = None

        if feature.zlib:
            unsafe_zlib = self.check_zlib_version(self.compiler.include_dirs)

        self.summary_report(feature, unsafe_zlib)
Beispiel #42
0
""" Test QiBuild Clean """
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function

import os
import platform
import py

import qisys.sh
import qibuild.config
import qibuild.profile
from qibuild.test.conftest import TestBuildWorkTree

TARGET = "{}-{}".format(platform.system().lower(),
                        platform.processor().lower())


def test_clean_build_dir(qibuild_action):
    """ Test Clean Build Dir """
    world_proj = qibuild_action.add_test_project("world")
    qibuild_action("configure", "world")
    qibuild_action("clean", "world")
    assert os.path.exists(world_proj.build_directory)
    qibuild_action("clean", "-f", "world")
    assert not os.path.exists(world_proj.build_directory)


def test_only_clean_one_build_dir(qibuild_action):
    """ Test Only Clean One Build Dir """
    qibuild.config.add_build_config("foo")
Beispiel #43
0
    def CheckArchitecture(self):

        # Fill with Python info
        import sys
        self.archi_info.python_version = sys.version.replace('\n', '')

        # Fill with Platform info
        import platform
        self.archi_info.platform = platform.system()
        self.archi_info.release = platform.release()

        # Fill with number of cores
        import multiprocessing
        self.archi_info.ncores = multiprocessing.cpu_count()

        # Is Mac
        platform_text = "Platform: " + self.archi_info.platform + " " + self.archi_info.release + " "
        if self.archi_info.platform.lower() in ['darwin', 'mac', 'macosx']:
            self.archi_info.isMac = True
            platform_text += '\x1b[32m' + '[MAC/OSX mode]' + '\x1b[0m'
        else:
            self.archi_info.isMac = False
            platform_text += '\x1b[32m' + '[Linux mode]' + '\x1b[0m'
        self.logger.info(platform_text)

        # Info for debug mode
        if self.debug:

            # Machine general
            import platform
            self.logger.debug("")
            self.logger.debug("Machine - Cross platform information")
            self.logger.debug(
                StringTools.Left("  Machine type:     ", 28) +
                str(platform.machine()))
            self.logger.debug(
                StringTools.Left("  Processor name:   ", 28) +
                str(platform.processor()))
            self.logger.debug(
                StringTools.Left("  Platform:         ", 28) +
                str(platform.platform()))
            self.logger.debug(
                StringTools.Left("  Platform release: ", 28) +
                str(platform.release()))
            self.logger.debug(
                StringTools.Left("  System:           ", 28) +
                str(platform.system()))
            self.logger.debug(
                StringTools.Left("  Node:             ", 28) +
                str(platform.node()))
            self.logger.debug(
                StringTools.Left("  Number of cores:  ", 28) +
                str(self.archi_info.ncores))
            self.logger.debug("")

            # Machine OS
            self.logger.debug("Machine - OS-specific information")
            try:
                tmp = platform.java_ver()
            except:
                tmp = ''
            self.logger.debug(
                StringTools.Left("  Java version:     ", 28) + str(tmp))
            try:
                tmp = platform.win32_ver()
            except:
                tmp = ''
            self.logger.debug(
                StringTools.Left("  Windows version:  ", 28) + str(tmp))
            try:
                tmp = platform.mac_ver()
            except:
                tmp = ''
            self.logger.debug(
                StringTools.Left("  Mac Os version:   ", 28) + str(tmp))
            try:
                tmp = platform.dist()
            except:
                tmp = ''
            self.logger.debug(
                StringTools.Left("  Unix distribution:", 28) +
                str(platform.platform()))
            self.logger.debug("")

        return True
Beispiel #44
0
#!/bin/env python
#!-*- coding:utf-8 -*-

import platform
#파이썬 코드 실행하는 운영체제 환경정보 제공 모듈
import multiprocessing
#CPU 갯수 카운트 모듈

print(u"운영체제:"), platform.system()
print(u"운영체제의 상세정보:"), platform.platform()
print(u"운영체제 버전:"), platform.version()
print(u"프로세서정보:"), platform.processor()
print(u"CPU 수:"), multiprocessing.cpu_count()
Beispiel #45
0
#!/usr/bin/env python
"""
CGI-Tools Python Package
Copyright (C) 2016 Assaf Gordon ([email protected])
License: BSD (See LICENSE file)
"""

from jinja2 import Template
import platform

sysdata = [
    platform.machine(),
    platform.node(),
    platform.processor(),
    platform.system()
]

pydata = [platform.python_implementation(), platform.python_version()]

print "Content-Type: text/html"
print  # blank line, end of headers

# Generate response HTML using Jinja2 Templating system
html_tmpl = """
<html>
<head>
Hello from Python CGI Script
<br/>
<br/>
System Data: <code>{{ system_data }}</code>
<br/>
Beispiel #46
0
                 and limitations under the License.
@python_version: 3.5
===============================================================================
"""


import os
import platform
import multiprocessing


# Cluto binary
CLUTO_VCLUSTER_BINARY = os.path.join(os.getcwd(),
                                     "bin",
                                     "cluto-2.1.2",
                                     platform.system()+"-"+platform.processor(),
                                     "vcluster")


# Maximum CPU cores on a node
CPU_CORE = multiprocessing.cpu_count()


# Source data options
SOURCE_DATASET = os.path.join(os.getcwd(), "data", "source", "Tipster")
SAMPLED_DATA_PATH = os.path.join(os.getcwd(), "output", "sample")
TRAINING_DATA = os.path.join(SAMPLED_DATA_PATH, "train")
TESTING_DATA = os.path.join(SAMPLED_DATA_PATH, "test")


# Benchmark data options
Beispiel #47
0
def processor():
    name = platform.processor()
    return name
Beispiel #48
0
def main():
    usage = "usage: %prog [-h|--help] [options]"
    parser = OptionParser(usage=usage)
    parser.add_option("-t",
                      "--throughput",
                      action="store_true",
                      dest="throughput",
                      default=False,
                      help="run throughput tests")
    parser.add_option("-l",
                      "--latency",
                      action="store_true",
                      dest="latency",
                      default=False,
                      help="run latency tests")
    parser.add_option("-b",
                      "--bandwidth",
                      action="store_true",
                      dest="bandwidth",
                      default=False,
                      help="run I/O bandwidth tests")
    parser.add_option("-i",
                      "--interval",
                      action="store",
                      type="int",
                      dest="check_interval",
                      default=None,
                      help="sys.setcheckinterval() value "
                      "(Python 3.8 and older)")
    parser.add_option("-I",
                      "--switch-interval",
                      action="store",
                      type="float",
                      dest="switch_interval",
                      default=None,
                      help="sys.setswitchinterval() value "
                      "(Python 3.2 and newer)")
    parser.add_option("-n",
                      "--num-threads",
                      action="store",
                      type="int",
                      dest="nthreads",
                      default=4,
                      help="max number of threads in tests")

    # Hidden option to run the pinging and bandwidth clients
    parser.add_option("",
                      "--latclient",
                      action="store",
                      dest="latclient",
                      default=None,
                      help=SUPPRESS_HELP)
    parser.add_option("",
                      "--bwclient",
                      action="store",
                      dest="bwclient",
                      default=None,
                      help=SUPPRESS_HELP)

    options, args = parser.parse_args()
    if args:
        parser.error("unexpected arguments")

    if options.latclient:
        kwargs = eval(options.latclient)
        latency_client(**kwargs)
        return

    if options.bwclient:
        kwargs = eval(options.bwclient)
        bandwidth_client(**kwargs)
        return

    if not options.throughput and not options.latency and not options.bandwidth:
        options.throughput = options.latency = options.bandwidth = True
    if options.check_interval:
        sys.setcheckinterval(options.check_interval)
    if options.switch_interval:
        sys.setswitchinterval(options.switch_interval)

    print("== %s %s (%s) ==" % (
        platform.python_implementation(),
        platform.python_version(),
        platform.python_build()[0],
    ))
    # Processor identification often has repeated spaces
    cpu = ' '.join(platform.processor().split())
    print("== %s %s on '%s' ==" % (
        platform.machine(),
        platform.system(),
        cpu,
    ))
    print()

    if options.throughput:
        print("--- Throughput ---")
        print()
        run_throughput_tests(options.nthreads)

    if options.latency:
        print("--- Latency ---")
        print()
        run_latency_tests(options.nthreads)

    if options.bandwidth:
        print("--- I/O bandwidth ---")
        print()
        run_bandwidth_tests(options.nthreads)
Beispiel #49
0
group   = os.getgroups()
where   = os.getcwd()
now     = time.time()
means   = time.ctime(now)

print ("User number",unumber)
print ("Process ID",pnumber)
print ("Login Name", login)
print ("Current Directory",where)
print ("Group", group)

print ("Name: " +socket.gethostname( ))
print ("FQDN: " +socket.getfqdn())
print ("System Platform: "+sys.platform)
print ("Node " +platform.node())
print ("Platform: "+platform.platform())
print ("System OS: "+platform.system())
print ("Release: " +platform.release())
print ("Version: " +platform.version())
print ("Python Version: " +platform.python_version())
print ("MacOS Version: " +platform.mac_ver()[0])
print ("Mac Address: " ,hex(mac))
# displaying platform architecture
print('Platform architecture:', platform.architecture())
# displaying platform processor
print('Platform processor:', platform.processor())
# displaying machine type
print('Machine type:', platform.machine())
# displaying system network name
print("System's network name:", platform.node())
Beispiel #50
0
def processor():
    return platform.processor()
Beispiel #51
0
 async def stats(self, ctx):
     """Posts bot stats."""
     oe = "<:wonline:544126607443492895>"
     ie = "<:widle:544126607669854219>"
     de = "<:wdnd:544126607485304843>"
     ge = "<:woffline:544126607711797253>"
     cmd = r'git show -s HEAD~3..HEAD --format="[{}](https://github.com/JonnyBoy2000/Kira-Miki/commit/%H) %s (%cr)"'
     if os.name == 'posix':
         cmd = cmd.format(r'\`%h\`')
     else:
         cmd = cmd.format(r'`%h`')
     try:
         revision = os.popen(cmd).read().strip()
     except OSError:
         revision = 'Could not fetch due to memory error. Sorry.'
     currentOS = platform.platform()
     cpuUsage = psutil.cpu_percent(interval=1)
     cpuThred = os.cpu_count()
     pythonMajor = sys.version_info.major
     pythonMinor = sys.version_info.minor
     pythonMicro = sys.version_info.micro
     pythonRelease = sys.version_info.releaselevel
     pyBit = struct.calcsize("P") * 8
     threadString = 'thread'
     if not cpuThred == 1:
         threadString += 's'
     memStats = psutil.virtual_memory()
     memUsed = memStats.used
     memTotal = memStats.total
     processor = platform.processor()
     memUsedGB = "{0:.1f}".format(((memUsed / 1024) / 1024) / 1024)
     memTotalGB = "{0:.1f}".format(((memTotal / 1024) / 1024) / 1024)
     memPerc = str(((memTotal / 1024) / 1024) / 1024 /
                   ((memUsed / 1024) / 1024) / 1024).split('.')[0]
     process = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'],
                                shell=False,
                                stdout=subprocess.PIPE)
     git_head_hash = process.communicate()[0].strip()
     dev = f"**Name:** {self.bot.get_user(170619078401196032)}\n**ID:** {self.bot.get_user(170619078401196032).id}"
     online = len([
         e.name for e in self.bot.get_all_members()
         if e.status == discord.Status.online
     ])
     idle = len([
         e.name for e in self.bot.get_all_members()
         if e.status == discord.Status.idle
     ])
     dnd = len([
         e.name for e in self.bot.get_all_members()
         if e.status == discord.Status.dnd
     ])
     offline = len([
         e.name for e in self.bot.get_all_members()
         if e.status == discord.Status.offline
     ])
     used = humanize.naturalsize(self.bot.lavalink.stats.memory.used)
     free = humanize.naturalsize(self.bot.lavalink.stats.memory.free)
     memory = f"**Used:** {used}\n"
     memory += f"**Free:** {free}\n"
     cpu = f"**Cores:** {self.bot.lavalink.stats.cpu.cores}\n"
     cpu += '**Cpu:** {}% of {} ({} {})\n'.format(cpuUsage, processor,
                                                  cpuThred, threadString)
     cpu += '**Ram:** {} ({}%) of {}GB used\n'.format(
         memUsedGB, memPerc, memTotalGB)
     lava = f"**Launched:** {humanize.naturaltime(datetime.datetime.utcnow() - datetime.timedelta(milliseconds=self.bot.lavalink.stats.uptime))}\n"
     lava += f"**Kira Players:** `{len(self.bot.lavalink.players._players)}` players are distributed.\n"
     lava += f"**Lavalink Cpu Load:** {round(self.bot.lavalink.stats.cpu.lavalink_load * 100)}%\n"
     basic = '**OS:** {}\n'.format(currentOS)
     basic += '**Hostname:** {}\n'.format(platform.node())
     basic += '**Language:** Python {}.{}.{} {} ({} bit)\n'.format(
         pythonMajor, pythonMinor, pythonMicro, pythonRelease, pyBit)
     basic += '**Commit:** {}\n'.format(git_head_hash.decode("utf-8"))
     basic += f"**Bot Uptime:** {self.get_bot_uptime(brief=True)}"
     members = f"{oe} {online}   | "
     members += f"{ie} {idle}\n"
     members += f"{de} {dnd}   | "
     members += f"{ge} {offline}"
     guilds = len(self.bot.guilds)
     e = discord.Embed()
     e.colour = 0x36393E
     e.set_thumbnail(url=self.bot.user.avatar_url)
     e.add_field(name="Basic:", value=basic)
     e.add_field(name="Dev:", value=dev)
     e.add_field(name="Guilds:", value=guilds)
     e.add_field(name="Members:", value=members)
     e.add_field(name="Lavalink:", value=lava)
     e.add_field(name="Memory:", value=memory)
     e.add_field(name="CPU | RAM:", value=cpu)
     e.add_field(name="Latest Changes:", value=revision)
     await ctx.send(embed=e)
Beispiel #52
0
def get_system_details(backends=True):
    """Return a dictionary with information about the system
    """
    buildno, builddate = platform.python_build()
    if sys.maxunicode == 65535:
        # UCS2 build (standard)
        unitype = 'UCS2'
    else:
        # UCS4 build (most recent Linux distros)
        unitype = 'UCS4'
    bits, linkage = platform.architecture()

    d = {
        'platform':
        platform.platform(),
        'processor':
        platform.processor(),
        'executable':
        sys.executable,
        'implementation':
        getattr(platform, 'python_implementation', lambda: 'n/a')(),
        'python':
        platform.python_version(),
        'compiler':
        platform.python_compiler(),
        'buildno':
        buildno,
        'builddate':
        builddate,
        'unicode':
        unitype,
        'bits':
        bits,
        'pyvisa':
        __version__,
        'backends':
        OrderedDict()
    }

    if backends:
        from . import highlevel
        for backend in highlevel.list_backends():
            if backend.startswith('pyvisa-'):
                backend = backend[7:]

            try:
                cls = highlevel.get_wrapper_class(backend)
            except Exception as e:
                d['backends'][backend] = [
                    'Could not instantiate backend',
                    '-> %s' % str(e)
                ]
                continue

            try:
                d['backends'][backend] = cls.get_debug_info()
            except Exception as e:
                d['backends'][backend] = [
                    'Could not obtain debug info',
                    '-> %s' % str(e)
                ]

    return d
 def __init__(self):
     """
     Método construtor.
     """
     self.__shell = Shell(AcaoQuandoOcorrerErro.REPETIR_E_IGNORAR, 10)
     self.__arquitetura = platform.processor()
Beispiel #54
0
def processor_detect():
    pi = pi_version(processor=True)
    if pi is None: return platform.processor()
Beispiel #55
0
 init_log(0)  # initialize logging service
 INSTALL_PROFILE = None
 try:
     try:
         INITSCR = setup_curses()
         WIN_SIZE_Y, WIN_SIZE_X = INITSCR.getmaxyx()
         if WIN_SIZE_Y < 24 or WIN_SIZE_X < 80:
             MSG = _("     Terminal too small. Min size is 80x24."
                     " Current size is %(x)ix%(y)i.") % \
                     {'x': WIN_SIZE_X, 'y': WIN_SIZE_Y}
             exit_text_installer(errcode=MSG)
         INSTALL_PROFILE = InstallProfile()
         INSTALL_PROFILE.log_location = OPTIONS.logname
         INSTALL_PROFILE.log_final = LOG_LOCATION_FINAL
         INSTALL_PROFILE.no_install_mode = OPTIONS.no_install
         if platform.processor() == "i386":
             INSTALL_PROFILE.is_x86 = True
         else:
             INSTALL_PROFILE.is_x86 = False
         SCREEN_LIST = ScreenList()
         MAIN_WIN = MainWindow(INITSCR,
                               SCREEN_LIST,
                               force_bw=OPTIONS.force_bw)
         SCREEN_LIST.help = HelpScreen(MAIN_WIN)
         WIN_LIST = make_screen_list(MAIN_WIN)
         SCREEN_LIST.screen_list = WIN_LIST
         SCREEN = SCREEN_LIST.get_next()
         CTRL_C = None
         while SCREEN is not None:
             logging.debug("Install profile:\n%s", INSTALL_PROFILE)
             logging.debug("Displaying screen: %s", type(SCREEN))
Beispiel #56
0
         print("Invalid second arguement")
     continue
 elif (command == "platform"):
     command = str(input("What element? >"))
     if (command == "type"):
         print(platform.machine())
     elif (command == "system"):
         print(platform.system())
     elif (command == "os"):
         print(platform.platform())
     elif (command == "ver"):
         print(platform.version())
     elif (command == "dvcmdl"):
         print(platform.uname())
     elif (command == "processor"):
         print(platform.processor())
     elif (command == "arch"):
         print(platform.architecture())
     elif (command == "node"):
         print(platform.node())
     elif (command == "pybuild"):
         print(platform.python_build())
     elif (command == "pyver"):
         print(platform.python_version())
     elif (command == "compiler"):
         print(platform.python_compiler())
     elif (command == "imp"):
         print(platform.python_implementation())
     elif (command == "release"):
         print(platform.release())
     else:
Beispiel #57
0
    def __init__(self, *args, mode=None):
        QApplication.__init__(self, *args)

        # Log some basic system info
        try:
            v = openshot.GetVersion()
            log.info("openshot-qt version: %s" % info.VERSION)
            log.info("libopenshot version: %s" % v.ToString())
            log.info("platform: %s" % platform.platform())
            log.info("processor: %s" % platform.processor())
            log.info("machine: %s" % platform.machine())
            log.info("python version: %s" % platform.python_version())
            log.info("qt5 version: %s" % QT_VERSION_STR)
            log.info("pyqt5 version: %s" % PYQT_VERSION_STR)
        except:
            pass

        # Setup appication
        self.setApplicationName('openshot')
        self.setApplicationVersion(info.SETUP['version'])

        # Init settings
        self.settings = settings.SettingStore()
        try:
            self.settings.load()
        except Exception as ex:
            log.error("Couldn't load user settings. Exiting.\n{}".format(ex))
            exit()

        # Init translation system
        language.init_language()

        # Tests of project data loading/saving
        self.project = project_data.ProjectDataStore()

        # Init Update Manager
        self.updates = updates.UpdateManager()

        # It is important that the project is the first listener if the key gets update
        self.updates.add_listener(self.project)

        # Load ui theme if not set by OS
        ui_util.load_theme()

        # Start libopenshot logging thread
        self.logger_libopenshot = logger_libopenshot.LoggerLibOpenShot()
        self.logger_libopenshot.start()

        # Track which dockable window received a context menu
        self.context_menu_object = None

        # Set unique install id (if blank)
        if not self.settings.get("unique_install_id"):
            self.settings.set("unique_install_id", str(uuid4()))

            # Track 1st launch metric
            import classes.metrics
            classes.metrics.track_metric_screen("initial-launch-screen")

        # Set Font for any theme
        if self.settings.get("theme") != "No Theme":
            # Load embedded font
            try:
                log.info(
                    "Setting font to %s" %
                    os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_id = QFontDatabase.addApplicationFont(
                    os.path.join(info.IMAGES_PATH, "fonts", "Ubuntu-R.ttf"))
                font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
                font = QFont(font_family)
                font.setPointSizeF(10.5)
                QApplication.setFont(font)
            except Exception as ex:
                log.error("Error setting Ubuntu-R.ttf QFont: %s" % str(ex))

        # Set Experimental Dark Theme
        if self.settings.get("theme") == "Humanity: Dark":
            # Only set if dark theme selected
            log.info("Setting custom dark theme")
            self.setStyle(QStyleFactory.create("Fusion"))

            darkPalette = self.palette()
            darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.WindowText, Qt.white)
            darkPalette.setColor(QPalette.Base, QColor(25, 25, 25))
            darkPalette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ToolTipBase, Qt.white)
            darkPalette.setColor(QPalette.ToolTipText, Qt.white)
            darkPalette.setColor(QPalette.Text, Qt.white)
            darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
            darkPalette.setColor(QPalette.ButtonText, Qt.white)
            darkPalette.setColor(QPalette.BrightText, Qt.red)
            darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
            darkPalette.setColor(QPalette.HighlightedText, Qt.black)
            darkPalette.setColor(QPalette.Disabled, QPalette.Text,
                                 QColor(104, 104, 104))
            self.setPalette(darkPalette)
            self.setStyleSheet(
                "QToolTip { color: #ffffff; background-color: #2a82da; border: 0px solid white; }"
            )

        # Create main window
        from windows.main_window import MainWindow
        self.window = MainWindow(mode)

        log.info('Process command-line arguments: %s' % args)
        if len(args[0]) == 2:
            path = args[0][1]
            if ".osp" in path:
                # Auto load project passed as argument
                self.window.open_project(path)
            else:
                # Auto import media file
                self.window.filesTreeView.add_file(path)

        # Reset undo/redo history
        self.updates.reset()
        self.window.updateStatusChanged(False, False)
Beispiel #58
0
######################################################################

try:
    conf['system'] = os.environ['UNAME']
except KeyError:
    conf['system'] = platform.system()

conf['Linux?'  ] = (conf['system'] == 'Linux')
conf['Solaris?'] = (conf['system'] == 'SunOS')
conf['Darwin?' ] = (conf['system'] == 'Darwin')
conf['FreeBSD?'] = (conf['system'] == 'FreeBSD')
conf['CYGWIN?' ] = (conf['system'] == 'CYGWIN')

conf['machine'] = platform.machine()

conf['processor'] = platform.processor()

conf['Intel?'] = (platform.machine() in ('i386', 'i486', 'i586', 'i686', 'x86_64',
                                         'AMD64', 'i86pc'))
conf['IA64?']   = (platform.processor() == 'ia64')
conf['PPC?']   = (platform.processor() == 'powerpc')
conf['SPARC?'] = (platform.processor() == 'sparc')

######################################################################
### bit width
######################################################################

conf['bits'] = platform.architecture()[0]

if os.environ.get('SAGE64', 'no') == 'yes':
    assert conf['bits'] == '64bit', 'SAGE64=yes on a 32-bit system!'
Beispiel #59
0
import platform

print "Operating System: " + platform.system()
print "OS Version: " + platform.release()
print "OS Minor Version: " + platform.version()
print "Network Name: " + platform.node()
print "Processor Type: " + platform.machine()
print "Processor Details: " + platform.processor()
print "Python Version: " + platform.python_version()
Beispiel #60
0
 def test_processor(self):
     res = platform.processor()