sys.platform.find

Here are the examples of the python api sys.platform.find taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

16 Examples 7

Example 1

Project: OwnTube
Source File: RawServer.py
View license
def autodetect_socket_style():
    if sys.platform.find('linux') < 0:
        return 1
    else:
        try:
            f = open('/proc/sys/net/ipv6/bindv6only', 'r')
            dual_socket_style = int(f.read())
            f.close()
            return int(not dual_socket_style)
        except:
            return 0

Example 2

Project: Herd
Source File: RawServer.py
View license
def autodetect_socket_style():
	if sys.platform.find('linux') < 0:
		return 1
	else:
		try:
			f = open('/proc/sys/net/ipv6/bindv6only','r')
			dual_socket_style = int(f.read())
			f.close()
			return int(not dual_socket_style)
		except:
			return 0

Example 3

Project: WxRobot
Source File: webwxapi.py
View license
    def genQRCode(self):
        if sys.platform.find('win') >= 0:
            self._genQRCodeImg()
            self._safe_open(QRCODE_PATH)
        else:
            mat = self._str2QRMat('https://login.weixin.qq.com/l/' + self.uuid)
            self._printQR(mat)

Example 4

Project: WxRobot
Source File: webwxapi.py
View license
    def _safe_open(self,file_path):
        try:
            if sys.platform.find('darwin') >= 0:
                subprocess.call(['open',file_path])
            elif sys.platform.find('linux') >= 0:
                subprocess.call(['xdg-open',file_path])
            else:
                os.startfile(file_path)
            return True
        except:
            return False

Example 5

Project: WxRobot
Source File: wxrobot.py
View license
    def open(self,path):
        pattern = path[-3:]
        if sys.platform.find('win') >= 0:
            os.startfile(path)
            return
        if pattern == 'jpg':
            r = self.api._safe_open(path)
            if not r:
                print('[*] 打开失败')
        elif pattern == 'mp3':
            subprocess.call(['mpg123',path])
        elif pattern == 'mp4':
            subprocess.call(['vlc',path])
        else:
            raise ValueError('the file format is wrong')

Example 6

Project: flumotion
Source File: greeter.py
View license
    def __init__(self, wizard, parent):
        super(Initial, self).__init__(wizard, parent)

        for radio in self.load_connection.get_group():
            if radio.name == 'start_new' and platform.find('win') >= 0:
                radio.hide()
            else:
                radio.connect('activate', self._on_radio__activiate)

Example 7

Project: FriendlyTorrent
Source File: RawServer.py
View license
def autodetect_socket_style():
	if sys.platform.find('linux') < 0:
		return 1
	else:
		try:
			f = open('/proc/sys/net/ipv6/bindv6only','r')
			dual_socket_style = int(f.read())
			f.close()
			return int(not dual_socket_style)
		except:
			return 0

Example 8

Project: BitTornado
Source File: RawServer.py
View license
def autodetect_socket_style():
    if sys.platform.find('linux') < 0:
        return 1
    else:
        try:
            with open('/proc/sys/net/ipv6/bindv6only', 'r') as f:
                dual_socket_style = int(f.read())
            return int(not dual_socket_style)
        except (IOError, ValueError):
            return 0

Example 9

Project: Ezhil-Lang
Source File: ezhil.py
View license
    @staticmethod
    def pidFileName( pid ):
        """ file name with $PID decoration as IPC alt """
        name = "ezhil_"+str(pid)+".out";
        if sys.platform.find('win') >= 0:
            # Windows OS
            name = tempfile.gettempdir()+name
        else:
            # LINUX or like systems
            name = "/tmp/"+name
        return name

Example 10

Project: desktop-mirror
Source File: crossplatform.py
View license
    @classmethod
    def get(cls):
        if hasattr(cls, 'sigleton'):
            return cls.singleton
        if sys.platform.find('linux') >= 0:
            cls.singleton = CrossPlatformUbuntu()
        else:
            cls.singleton = CrossPlatformWindows()
        return cls.singleton

Example 11

Project: p2ptv-pi
Source File: RawServer.py
View license
def autodetect_socket_style():
    if sys.platform.find('linux') < 0:
        res = 1
    else:
        try:
            f = open('/proc/sys/net/ipv6/bindv6only', 'r')
            dual_socket_style = int(f.read())
            f.close()
            res = int(not dual_socket_style)
        except:
            res = 0

    if DEBUG2:
        log('rawserver::autodetect_socket_style:', res)
    return res

Example 12

Project: DIRAC
Source File: Subprocess.py
View license
  def systemCall( self, cmdSeq, callbackFunction = None, shell = False, env = None ):
    """ system call (no shell) - execute :cmdSeq: """

    if shell:
      self.log.verbose( 'shellCall:', cmdSeq )
    else:
      self.log.verbose( 'systemCall:', cmdSeq )

    self.cmdSeq = cmdSeq
    self.callback = callbackFunction
    if sys.platform.find( "win" ) == 0:
      closefd = False
    else:
      closefd = True
    try:
      self.child = subprocess.Popen( self.cmdSeq,
                                     shell = shell,
                                     stdout = subprocess.PIPE,
                                     stderr = subprocess.PIPE,
                                     close_fds = closefd,
                                     env = env )
      self.childPID = self.child.pid
    except OSError, v:
      retDict = S_ERROR( v )
      retDict['Value'] = ( -1, '' , str( v ) )
      return retDict
    except Exception as x:
      try:
        self.child.stdout.close()
        self.child.stderr.close()
      except Exception:
        pass
      retDict = S_ERROR( x )
      retDict['Value'] = ( -1, '' , str( x ) )
      return retDict

    try:
      self.bufferList = [ [ "", 0 ], [ "", 0 ] ]
      initialTime = time.time()

      exitStatus = self.__poll( self.child.pid )

      while ( 0, 0 ) == exitStatus or None == exitStatus:
        retDict = self.__readFromCommand()
        if not retDict[ 'OK' ]:
          return retDict

        if self.timeout and time.time() - initialTime > self.timeout:
          exitStatus = self.killChild()
          self.__readFromCommand()
          return self.__generateSystemCommandError( exitStatus,
                                                    "Timeout (%d seconds) for '%s' call" %
                                                    ( self.timeout, cmdSeq ) )
        time.sleep( 0.01 )
        exitStatus = self.__poll( self.child.pid )

      self.__readFromCommand()

      if exitStatus:
        exitStatus = exitStatus[1]

      if exitStatus >= 256:
        exitStatus /= 256
      return S_OK( ( exitStatus, self.bufferList[0][0], self.bufferList[1][0] ) )
    finally:
      try:
        self.child.stdout.close()
        self.child.stderr.close()
      except Exception:
        pass

Example 13

Project: desktop-mirror
Source File: crossplatform.py
View license
    def is_linux(self):
        if sys.platform.find('linux') >= 0:
            return True
        return False

Example 14

Project: desktop-mirror
Source File: crossplatform.py
View license
    def is_windows(self):
        if sys.platform.find('win') >= 0:
            return True
        return False

Example 15

Project: ahc
Source File: helpers.py
View license
def isLinux():
	if platform.find('linux') != -1:
		return True
	return False

Example 16

Project: MRI
Source File: keyconfig.py
View license
    def __init__(self, ctx):
        KeyConfigLoader.__init__(self, ctx)
        #self.config = Config()
        self.entries = None
        self.keys = None
        self.keys_list = None
        self.keys_edit = None
        self.font = None
        self.width = None
        self.space_width = None
        self._mod = 0 # current
        self._key = 0
        self.macros_dlg = None
        self._macros = macros.Macros(self)
        
        self.EXTENSION_DIALOGS = mytools_Mri.values.MRI_DIR + "/dialogs/"
        # check os type
        import sys
        if sys.platform.find("mac") >= 0:
            KeyConfig.MOD_3 = KeyConfig.MOD__