本文整理汇总了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"
)