本文整理匯總了Python中sys.platform.lower方法的典型用法代碼示例。如果您正苦於以下問題:Python platform.lower方法的具體用法?Python platform.lower怎麽用?Python platform.lower使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sys.platform
的用法示例。
在下文中一共展示了platform.lower方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: read
# 需要導入模塊: from sys import platform [as 別名]
# 或者: from sys.platform import lower [as 別名]
def read(self, file_path: str) -> None:
if not isfile(file_path):
raise FileNotFoundError("File {} does not exists".format(file_path))
if file_path.lower().endswith(".gz") and cbclib.Cbc_supportsGzip() == CHAR_ZERO:
raise MipBaseException("CBC not compiled with gzip support")
if (
file_path.lower().endswith(".bz2")
and cbclib.Cbc_supportsBzip2() == CHAR_ZERO
):
raise MipBaseException("CBC not compiled with bzip2 support")
fpstr = file_path.encode("utf-8")
if ".mps" in file_path.lower():
cbclib.Cbc_readMps(self._model, fpstr)
elif ".lp" in file_path.lower():
cbclib.Cbc_readLp(self._model, fpstr)
else:
raise ValueError(
"Enter a valid extension (.lp or .mps) \
to indicate the file format"
)
示例2: get_os
# 需要導入模塊: from sys import platform [as 別名]
# 或者: from sys.platform import lower [as 別名]
def get_os():
if platform.lower() == 'darwin':
return 'osx'
elif platform.lower().startswith('linux'):
return 'linux'
else:
# throw is better
return 'unknown'
示例3: get_token
# 需要導入模塊: from sys import platform [as 別名]
# 或者: from sys.platform import lower [as 別名]
def get_token(self, url):
token = ''
path = os.getcwd()
if _platform == "Windows" or _platform == "win32":
# Check if we are on 32 or 64 bit
file_name= 'chromedriver.exe'
if _platform.lower() == "darwin":
file_name= 'chromedriver'
if _platform.lower() == "linux" or _platform.lower() == "linux2":
file_name = 'chromedriver'
full_path = ''
if os.path.isfile(path + '/' + file_name): # check local dir first
full_path = path + '/' + file_name
if full_path == '':
self.bot.logger.error(file_name + ' is needed for manual captcha solving! Please place it in the bots root directory')
sys.exit(1)
try:
driver = webdriver.Chrome(full_path)
driver.set_window_size(600, 600)
except Exception:
self.bot.logger.error('Error with Chromedriver, please ensure it is the latest version.')
sys.exit(1)
driver.get(url)
elem = driver.find_element_by_class_name("g-recaptcha")
driver.execute_script("arguments[0].scrollIntoView(true);", elem)
self.bot.logger.info('You have 1 min to solve the Captcha')
try:
WebDriverWait(driver, 60).until(EC.text_to_be_present_in_element_value((By.NAME, "g-recaptcha-response"), ""))
token = driver.execute_script("return grecaptcha.getResponse()")
driver.close()
except TimeoutException, err:
self.bot.logger.error('Timed out while trying to solve captcha')
示例4: sys_is_windows
# 需要導入模塊: from sys import platform [as 別名]
# 或者: from sys.platform import lower [as 別名]
def sys_is_windows():
""" Check if user is running the code on Windows machine
:return: `True` if OS is Windows and `False` otherwise
:rtype: bool
"""
return platform.lower().startswith('win')
示例5: can_handle_current_platform
# 需要導入模塊: from sys import platform [as 別名]
# 或者: from sys.platform import lower [as 別名]
def can_handle_current_platform(self):
"""Returns true if this platform object can handle the server this process is running on.
@return: True if this platform instance can handle the current server.
@rtype: bool
"""
return _platform.lower().startswith("linux")
示例6: write
# 需要導入模塊: from sys import platform [as 別名]
# 或者: from sys.platform import lower [as 別名]
def write(self, file_path: str):
fpstr = file_path.encode("utf-8")
if ".mps" in file_path.lower():
cbclib.Cbc_writeMps(self._model, fpstr)
elif ".lp" in file_path.lower():
cbclib.Cbc_writeLp(self._model, fpstr)
else:
raise ValueError(
"Enter a valid extension (.lp or .mps) \
to indicate the file format"
)