def get(self): r = self.get_argument('r', '') if not r: self.write('参数错误') return openid = utils.decrypt(r) user_agent = self.request.headers.get('User-Agent', '') platform = utils.get_platform(user_agent) # 判断用户系统是否已知 user_info = users.get_info(openid) if not user_info['platform']: ip = self.request.remote_ip ip_address = IP.find(ip) users.set_ip(openid, ip, ip_address, platform) if user_info['status'] == -2: self.write("非法用户") return if platform == 2: url = urlparse.urljoin(constants.SITE_BASEURL, 'v1/applist/goandroid') self.redirect(url, False, 302) return aes = AESCipher() r = aes.encode(openid) url = 'http://w.ymapp.com/wx/ios/lists.html?r=%s' % r #url = 'http://au.youmi.net/wx/ios/lists.html?r=%s' % r self.redirect(url, False, 302)
def run(): log.info("Welcome to myHouse v" + conf["constants"]["version"]) log.info("Platform: " + utils.get_platform()) # initialize the database initialized = db.init() if not initialized: sys.exit(1) # start the scheduler schedule.start() # schedule backup backup.schedule_all() # schedule all sensors if conf['sensors']['enabled']: sensors.schedule_all() # schedule all alerts if conf['alerter']['enabled']: alerter.schedule_all() # run all input services input.run() # start the web server if conf['gui']['enabled']: schedule.add_job(webserver.run, 'date', run_date=datetime.datetime.now()) # run the pws service if conf['pws']['enabled']: pws.schedule_all() # run as a deamon while True: time.sleep(1)
def getRepoName(self, date): # sneaking this in here if get_platform()['name'] == "Windows" and date < datetime.date( 2010, 03, 18): # no .zip package for Windows, can't use the installer print "Can't run Windows builds before 2010-03-18" sys.exit()
def get(self, platform_name): build_type = str(self.request.get('type')) platform = get_platform(platform_name) if not platform: return self.redirect('https://www.youtube.com/embed/o_asQwJqWCI?t=16&autoplay=1') self.redirect(platform.get_last_build_url(build_type))
def get(self, platform_name): build_type = str(self.request.get('type')) platform = get_platform(platform_name) if not platform: return self.redirect( 'https://www.youtube.com/e/o_asQwJqWCI?autoplay=1&start=16') self.redirect(platform.get_last_build_url(build_type))
def config_load(): path_project_root = str(get_project_root()) platform = utils.get_platform() if platform == 'Linux': return toml.load(path_project_root + "/config/config.toml") elif platform == 'Windows': return toml.load(path_project_root + "\\config\\config.toml")
def __init__(self, ctx: click.Context, verbose: bool): """Basic content for CLI.""" ctx.params['log_level'] = verbose platform = utils.get_platform() self.game_flavour = 'vanilla_classic' if platform == 'classic_era' else platform self.manager = InstawowManager(self.game_flavour, False) self.manager_lib = InstawowManager(self.game_flavour, True) ctx.call_on_close(self.manager.conn.close) ctx.call_on_close(self.manager_lib.conn.close)
def connect(self): if "Windows" == utils.get_platform(): import mysql.connector connect_func = mysql.connector.Connect elif "Linux" == utils.get_platform(): import MySQLdb connect_func = MySQLdb.connect else: self.logger.error(__name__, "Platform is {}, not supported".format(utils.get_platform())) return False try: self.con = connect_func(**self.config) self.logger.debug(__name__, "connect database success : {}".format(self.config)) except Exception as e: self.logger.error(__name__, "connect database fails! config:{} , {}".format(e, self.config)) if not self.con: return False self.cur = self.con.cursor() return True
def _is_attribute_available_for_platform(self, attribute): current_platform_listed = False; if 'platforms' in attribute.attrib: platforms = self._process_platforms(attribute.attrib['platforms']) if utils.get_platform() in platforms: current_platform_listed = True; else: # 'platform' specification is missing so this attribute is available for all platforms current_platform_listed = True return current_platform_listed
def __init__(self, build_target: str, main_compiler: str, use_cuda: bool): assert (main_compiler == 'gcc' or main_compiler == 'msvc') self._build_target = build_target self._platform = get_platform() if self._platform == 'linux': assert (main_compiler == 'gcc') self._main_compiler = main_compiler self._objects = [] self._use_cuda = use_cuda self._path_to_cuda = 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\'
def test_QueueDataset_train(self): """test QueueDataset in train.""" self.yaml_config_name = sys._getframe().f_code.co_name + '.yaml' if six.PY3: self.yaml_content["dataset"][0]["type"] = "DataLoader" else: self.yaml_content["dataset"][0]["type"] = "QueueDataset" self.run_yaml() built_in.equals(self.pro.returncode, 0, self.err_msg) built_in.not_contains(self.err, 'Traceback', self.err_msg) built_in.regex_match_len(self.out, 'epoch.+done', 2, self.err_msg) # NOTE windows和mac直接会强行切换到dataloader check_type = "DataLoader" if utils.get_platform( ) != "LINUX" else "QueueDataset" if six.PY3: check_type = "DataLoader" else: check_type = "DataLoader" if utils.get_platform( ) != "LINUX" else "QueueDataset"
def __init__(self, boost_path, config=None, remove_boost = False): print 0 boost_path = os.path.abspath(boost_path) if boost_path else None self._platform = utils.get_platform() self._boost_path = boost_path self._remove_boost = remove_boost self._boost_config = config.get_module(self._boost_name) self._process_config(self._boost_config) if not self._boost_path or not os.path.exists(self._boost_path): g_log.warning("Boost location %s doesn't exist" % self._boost_path) sys.exit(0)
def getPlatformString(self): platform = get_platform() if platform['name'] == "Windows": return "win32" elif platform['name'] == "Linux": if platform['bits'] == '64': return "linux64" return "linux" elif platform['name'] == "Mac": return "macosx64" print "ERROR, couldn't get platform." quit()
def test_QueueDataset_train_gpu(self): """test QueueDataset in train with gpu""" self.yaml_config_name = sys._getframe().f_code.co_name + '.yaml' self.yaml_content["runner"][0]["device"] = 'gpu' self.yaml_content["dataset"][0]["type"] = "QueueDataset" self.run_yaml() built_in.equals(self.pro.returncode, 0, self.err_msg) built_in.not_contains(self.err, 'Traceback', self.err_msg) built_in.regex_match_len(self.out, self.epoch_re, 2, self.err_msg) # NOTE windows和mac直接会强行切换到dataloader if utils.get_platform() != "LINUX" or not six.PY2: check_type = "DataLoader" else: check_type = "QueueDataset"
def __init__(self, repo_name=None): platform=get_platform() if platform['name'] == "Windows": if platform['bits'] == '64bit': print "No nightly builds available for 64 bit Windows" sys.exit() self.buildRegex = ".*win32.zip" self.processName = self.name + ".exe" self.binary = "moznightlyapp/" + self.name + "/" + self.name + ".exe" elif platform['name'] == "Linux": self.processName = self.name + "-bin" self.binary = "moznightlyapp/" + self.name + "/" + self.name if platform['bits'] == '64bit': self.buildRegex = ".*linux-x86_64.tar.bz2" else: self.buildRegex = ".*linux-i686.tar.bz2" elif platform['name'] == "Mac": self.buildRegex = ".*mac.*\.dmg" self.processName = self.name + "-bin" self.binary = "moznightlyapp/Mozilla.app/Contents/MacOS/" + self.name + "-bin" self.repo_name = repo_name
def __init__(self, name="firefox", installDir=os.path.join(os.path.expanduser("~"),"remotebisectorapp")): self.name = name platform=get_platform() if platform['name'] == "Windows": if platform['bits'] == '64': print "No builds available for 64 bit Windows" sys.exit() self.buildRegex = ".*win32.zip" self.processName = self.name + ".exe" self.binary = os.path.join(installDir, self.name, self.name + ".exe") elif platform['name'] == "Linux": self.processName = self.name + "-bin" self.binary = os.path.join(installDir, self.name, self.name) if platform['bits'] == '64': self.buildRegex = ".*linux-x86_64.tar.bz2" else: self.buildRegex = ".*linux-i686.tar.bz2" elif platform['name'] == "Mac": self.buildRegex = ".*mac.*\.dmg" self.processName = self.name + "-bin" self.binary = os.path.join(installDir, "Mozilla.app/Contents/MacOS", self.name + "-bin")
def getRepoName(self, date): # sneaking this in here if get_platform()['name'] == "Windows" and date < datetime.date(2010, 03, 18): # no .zip package for Windows, can't use the installer print "Can't run Windows builds before 2010-03-18" sys.exit()
cfg['abs_updater_path'] = os.path.normpath( cfg['abs_target_path'] + '/' + cfg['updater_path'] ) if 'binary_path' not in cfg: cfg['binary_path'] = '' output['install_path'] = cfg['install_path'] if output['install_path'][0] is not '/': output['install_path'] = '/' + output['install_path'] output['remote_project_path'] = cfg['remote_project_path'] if output['remote_project_path'][0] is not '/': output['remote_project_path'] = '/' + output['remote_project_path'] if 'platforms' not in cfg: cfg['platforms'] = [ get_platform() ] cfg['abs_deploy_base'] = os.path.normpath(os.path.abspath(cfg['abs_target_path'] + '/' + cfg['local_project_path'])) cfg['abs_content_path'] = os.path.normpath( cfg['abs_deploy_base'] + '/' ) #print( 'Absolute deploy path: %s' % cfg['abs_deploy_base'] ) else: print( 'Configuration %s not found' % config_path ) sys.exit(1) cfg['output_file'] = os.path.normpath( cfg['abs_target_path'] + '/' + PRECACHE_FILE ) def add_file_data( fullpath, relative_path, filedata ): filedata['path'] = relative_path
#!/usr/bin/env python # -*- coding: utf-8 -*- from bs4 import BeautifulSoup import copy import os import shutil import sys import re from datetime import datetime import pytz import utils # print 'Args:', str(sys.argv) print 'Platform:', utils.get_platform(sys.argv) def create_summary(doc, heading_text): summary = doc.new_tag("summary") wrapper = doc.new_tag("span", **{'class': 'wrapper'}) heading = doc.new_tag("span", **{'class': 'heading'}) heading.string = heading_text wrapper.append(heading) pill = doc.new_tag("span", **{'class': 'pill'}) wrapper.append(pill) summary.append(wrapper)
import json import time import json import utils import logger import config log = logger.get_logger(__name__) conf = config.get_config() import sensors # variables plugin_conf = conf['plugins']['gpio'] pins = {} platform = utils.get_platform() supported_platform = True if platform != "unknown" else False # initialize the GPIO if plugin_conf["enabled"]: # import GPIO module if platform == "raspberry_pi": import RPi.GPIO as GPIO elif platform == "orange_pi": import OPi.GPIO as GPIO # initialize GPIO if supported_platform: GPIO.setwarnings(False) mode = GPIO.BCM if plugin_conf["mode"] == "bcm" else GPIO.BOARD GPIO.setmode(mode) # register a new sensor against this plugin
cfg['abs_updater_path'] = os.path.normpath(cfg['abs_target_path'] + '/' + cfg['updater_path']) if 'binary_path' not in cfg: cfg['binary_path'] = '' output['install_path'] = cfg['install_path'] if output['install_path'][0] is not '/': output['install_path'] = '/' + output['install_path'] output['remote_project_path'] = cfg['remote_project_path'] if output['remote_project_path'][0] is not '/': output['remote_project_path'] = '/' + output['remote_project_path'] if 'platforms' not in cfg: cfg['platforms'] = [get_platform()] cfg['abs_deploy_base'] = os.path.normpath( os.path.abspath(cfg['abs_target_path'] + '/' + cfg['local_project_path'])) cfg['abs_content_path'] = os.path.normpath(cfg['abs_deploy_base'] + '/') #print( 'Absolute deploy path: %s' % cfg['abs_deploy_base'] ) else: print('Configuration %s not found' % config_path) sys.exit(1) cfg['output_file'] = os.path.normpath(cfg['abs_target_path'] + '/' + PRECACHE_FILE)
def platform(self): user_agent = self.request.headers['User-Agent'] return utils.get_platform(user_agent)
note = new_doc.new_tag("p", **{'class': 'note'}) note.string = n body.append(note) header = utils.get_header(platform) html.append(header) html.append(body) new_doc.append(html) # Write to disk f = open(target_path, "w+") f.write(str(new_doc)) PLATFORM = utils.get_platform(sys.argv) SOURCE_DIR = "./in" TARGET_DIR = utils.get_target_dir(PLATFORM) # Transform for subdir, dirs, files in os.walk(SOURCE_DIR): target_path = utils.source_to_target_path(subdir, TARGET_DIR) utils.create_dir_if_not_exists(target_path) for file in files: source_path = os.path.join(subdir, file) _, ext = os.path.splitext(source_path) target_path = utils.source_to_target_path(source_path, TARGET_DIR) if (ext == ".json"):
def OnInit(self): global client_id utils.assert_folders() utils.migrate_from_tmp() try: setup_log() except: wx.MessageBox('Another instance of Assembly is running', 'Unable to start',wx.OK | wx.ICON_ERROR) sys.exit(0) platform = utils.get_platform() auto_upgrade = utils.string2bool(platform['autoupgrade']) if len(sys.argv) > 1: utils.add_user_attribute('show_info_popup','True') utils.delete_folder_async('%s/upgrade' %os.getcwd()) wx.MessageBox('Congratulations! Assembly64 was upgraded from version %s to %s.' %(sys.argv[1], version), 'Assembly64 upgraded!',wx.OK | wx.ICON_INFORMATION) try: utils.update_server_db() newer_available,force,available_version = utils.check_version(version) if newer_available and force: update_dia = UpdateDialog(None,"New version available", "New version available. Upgrade is vital!",auto_upgrade, True) update_dia.ShowModal() if update_dia.is_app_upgrade(): upgrade = UpgradeSplash() upgrade.Show() utils.do_upgrade(upgrade,version,platform) os._exit(1) elif newer_available and not force: update_dia = UpdateDialog(None,"New version available", "New version available, but you can stay with this one.. For now!", auto_upgrade, False) update_dia.ShowModal() if update_dia.is_app_upgrade(): upgrade = UpgradeSplash() upgrade.Show() utils.do_upgrade(upgrade,version,platform) os._exit(1) except FtpOverloadedException: wx.MessageBox('Too many users right now, please try later', 'Assembly Error',wx.OK | wx.ICON_WARNING) sys.exit(0) except ftplib.all_errors as a: wx.MessageBox('Unable to communicate with Assembly64 server.', 'Assembly Error',wx.OK | wx.ICON_WARNING) sys.exit(0) except: wx.MessageBox('Unable to communicate with assembly64 server.', 'Assembly Error',wx.OK | wx.ICON_WARNING) sys.exit(0) if not utils.has_attribute('uid'): client_id = str(uuid.uuid1()) utils.add_user_attribute('uid',client_id) post_ga_event('application','startup_new_user') else: client_id = utils.get_user_attribute('uid') post_ga_event('application','startup_existing_user') if not utils.has_attribute('show_info_popup'): utils.add_user_attribute('show_info_popup','true') if utils.has_attribute(delete_files_after_install) is False: utils.add_user_attribute(delete_files_after_install,'true') thread = Thread(target = update_db,args = (10, )) thread.start() AssemblySplash().Show() return 1