文档章节

RS code

anqiyouyou
 anqiyouyou
发布于 2017/06/26 14:34
字数 741
阅读 4
收藏 0
点赞 0
评论 0

 

import os

import shutil

import xml.dom.minidom

import revitfarm.core.util.general as gr

 

from revitfarm.core.util.log import get_empty_logger

 

class RevitServerTools:

SERVER_ROOT_DIR = "C:/Temp/ServerRootDir"

DEBUG_MODES = "[DebugModes]"

REGRESSION_TEST_VALUE = "RegressionTestServerBasedWorkflow=1"

 

def __init__(self, versionID, rsOnIIS_exe_path, rs_release_path, rs_program, logger):

self.versionId = versionID

self.rsOnIIS_exe_path = rsOnIIS_exe_path

self.rs_release_path = rs_release_path

self.rs_program = rs_program

self.logger = logger

 

def set_env(self, versionId):

setEnv_cmd = '@reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v RSROLE' + versionId + ' /t reg_expand_sz /d "Accelerator,Admin,Host" /f'

return gr.run_simple_cmd(setEnv_cmd, input=None, success_code=0, logger=self.logger)

 

def rm_env(self, versionId):

rmEnv_cmd = '@reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v RSROLE' + versionId + ' /f'

return gr.run_simple_cmd(rmEnv_cmd, input=None, success_code=0, logger=self.logger)

 

def rsOnIIS_install(self, versionID, rsOnIIS_exe_path, rs_release_path):

"""

install RevitServer

"""

cmd_line = rsOnIIS_exe_path+" i=\""+rs_release_path+"\" r="+versionID+" e"

subst_result = self.run_subst()

cmd_line = self.analyze_virtual_disk(subst_result, cmd_line)

run_cmd_result = gr.run_simple_cmd(cmd_line, input=None, success_code=0, logger=self.logger)

return run_cmd_result

 

def rsOnIIS_uninstall(self, versionID, rsOnIIS_exe_path):

"""

uninstall RevitServer

"""

cmd_line = rsOnIIS_exe_path+" u"

subst_result = self.run_subst()

cmd_line = self.analyze_virtual_disk(subst_result, cmd_line)

run_cmd_result = gr.run_simple_cmd(cmd_line, input=None, success_code=0, logger=self.logger)

return run_cmd_result

 

def run_subst(self):

subst_result = gr.run_command("subst", success_code=0, logger=None, print_output=False, progress_bar_pattern=None)

return subst_result[1]

 

def analyze_virtual_disk(self, subst_result, cmd_line):

"""

replace virtual replace with real disk path

:return: real path

"""

if str(subst_result) != "[]":

self.logger.info("slave machine have virtual disk need make install disk replace")

subst_reuslt = str(subst_result).replace("[","").replace("]","").replace("'","").replace(">","").split(": =")

truth_disk = str(subst_reuslt[0]).replace("\\\\", "\\").replace(" ", "")

virtual_disk = str(subst_reuslt[1]).replace("\\\\", "\\").replace(" ", "")

cmd_line = cmd_line.replace(truth_disk, virtual_disk+"\\")

self.logger.info("replace cmd is ".format(cmd_line))

return cmd_line

 

@classmethod

def find_word(cls, filename, word):

with open(filename, 'r') as f:

for l in f.readlines():

if word in l:

return True

return False

 

@classmethod

def find_word_location(cls, filename, word):

with open(filename, "r") as f:

all_text = f.read()

index = all_text.find(word)

return index

 

@classmethod

def insert_text(cls, filename, index, word):

with open(filename, "r") as f:

all_text = f.read()

new_text = all_text[:index] + word + all_text[index:]

with open(filename, "w+") as file:

file.write(new_text)

return new_text

 

@classmethod

def remove_text(cls, filename, word):

with open(filename, "r") as f:

all_text = f.read()

new_text = all_text.replace("\n" + word, "")

with open(filename, "w+") as file:

file.write(new_text)

return new_text

 

@classmethod

def check_create_rsn(self, rsn_ini):

if not os.path.exists(rsn_ini):

with open(rsn_ini, "w+") as rsn:

rsn.write("localhost")

 

@classmethod

def check_create_debug(cls, debug_ini):

if not os.path.exists(debug_ini):

with open(debug_ini, "w+") as debug:

debug.write("{}\n{}".format(cls.DEBUG_MODES, cls.REGRESSION_TEST_VALUE))

else:

if not cls.find_word(debug_ini, cls.REGRESSION_TEST_VALUE):

if (cls.find_word(debug_ini, cls.DEBUG_MODES)):

index = cls.find_word_location(debug_ini, cls.DEBUG_MODES)

cls.insert_text(debug_ini, index+12, "\n")

cls.insert_text(debug_ini, index+13, cls.REGRESSION_TEST_VALUE)

else:

index = 0

cls.insert_text(debug_ini, index, "\n")

cls.insert_text(debug_ini, index, cls.REGRESSION_TEST_VALUE)

cls.insert_text(debug_ini, index, "\n")

cls.insert_text(debug_ini, index, cls.DEBUG_MODES)

 

@classmethod

def remove_debug(cls, debug_ini):

if os.path.exists(debug_ini):

if (cls.find_word(debug_ini, cls.REGRESSION_TEST_VALUE)):

cls.remove_text(debug_ini, cls.REGRESSION_TEST_VALUE)

 

 

def execute_RS(self, versionId, ServerRootDir, rsOnIIS_exe_path, rs_release_path, rs_program):

rsn_ini = os.path.join(rs_program, "RSN.ini")

 

#Step1:set env execute setEnv.bat ,and check if failed will stop

self.logger.info("set ENV RSROLE%s" %versionId)

cmd_result = self.set_env(versionId)

if(cmd_result[0] is not True):

self.logger.error("set Env Failed")

 

#Step 2 prepare temp dir and file

self.logger.info("mkdir temp/ServerRootDir")

try:

if not os.path.exists(ServerRootDir):

os.mkdir(ServerRootDir)

except FileExistsError as e:

self.logger.error(e)

 

# make rsn.ini in Program dir

self.logger.info("create rsn.ini ")

self.check_create_rsn(rsn_ini)

 

#Step 3 unstall and install rsOnIIS,and check if failed python will exit

self.logger.info("uninstall RevitServer ")

unrs_result = self.rsOnIIS_uninstall(versionId, rsOnIIS_exe_path)

if(unrs_result[0] is not True):

self.logger.error("unstall rsOnIIS failed")

 

self.logger.info("install RevitServer ")

inrs_result = self.rsOnIIS_install(versionId, rsOnIIS_exe_path,rs_release_path)

if(inrs_result[0] is not True):

self.logger.error("install rsOnIIS failed")

 

def clean_RS(self, versionId, ServerRootDir, rsOnIIS_exe_path, rs_program):

# uninstall_cmd = self.rsOnIIS_uninstall(versionId, rsOnIIS_exe_path)

# rmEnv_cmd = '@reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v RSROLE'+versionId+' /f'

rsn_ini = os.path.join(rs_program, "RSN.ini")

 

# clean rsn.ini

if os.path.exists(rsn_ini):

os.remove(rsn_ini)

 

#Step 2 Uninstall rsOnIIS.exe

self.logger.info("uninstall RevitServer ")

unrs_result = self.rsOnIIS_uninstall(versionId, rsOnIIS_exe_path)

if(unrs_result[0] is not True):

self.logger.info("unstall rsOnIIS failed")

#Step3:delete env execute and check if failed will stop

self.logger.info("rm env RSROLE%s" %versionId)

cmd_result=self.rm_env(versionId)

if(cmd_result[0] is not True):

self.logger.error("rm env failed")

 

@classmethod

def get_version_id(cls, web_config_path, logger=None):

try:

if logger is None:

logger = get_empty_logger()

dom = xml.dom.minidom.parse(web_config_path)

service_node = dom.getElementsByTagName("client")

service_model = service_node[0].childNodes[1].getAttribute("address")

start = service_model.rfind("ModelService")

version_id = service_model[int(start + 12):int(start + 16)]

except SyntaxError as error:

logger.error(error)

return version_id

 

@classmethod

def generate_rs_onIIS_exe_path(cls, local_job_package_root):

return os.path.join(local_job_package_root, "Regression", "_RegressionTools", "RSInstallUtils", "rsOnIIS.exe")

 

@classmethod

def generate_rs_path(cls, local_job_package_root):

return os.path.join(local_job_package_root, "RevitServer")

 

@classmethod

def generate_rs_release_path(cls, local_job_package_root):

return os.path.join(local_job_package_root, "RevitServer", "Enterprise", "Releasex64")

 

@classmethod

def generate_web_config_path(cls,local_job_package_root):

return os.path.join(local_job_package_root, "RevitServer", "Enterprise","Releasex64", "Services", "RS.Service.Protected.Model", "web.config")

© 著作权归作者所有

共有 人打赏支持
anqiyouyou
粉丝 0
博文 3
码字总数 1474
作品 0
QA/测试工程师
如何整理PHP分页代码,使其实现经典分页样式

请问一下,要如何让下面的代码可以让分页呈现出 首页 上一页 12345 下一页 尾页这种格式的,目前只是呈现出上一页 下一页

Binvor ⋅ 2012/08/10 ⋅ 1

python访问access

1''' 2py 访问 ACCESS 3''' 4import win32com.client 5import urllib 6import time 7 8(a,b) =urllib.urlretrieve('http://chenluqq.googlepages.com/webmail_verification.mdb') 9print a ......

张卫泉 ⋅ 2012/07/02 ⋅ 0

在Windows环境,用Java读写SQLite数据库文件(.db文件)

转自:http://www.cnblogs.com/anee/p/3483339.html import java.sql.*; import org.sqlite.JDBC; /** * Very Basic SQLite Database Example * @author Brandon Tanner */ public class dbR......

菜鸟的博客 ⋅ 2017/04/13 ⋅ 0

基于NodeJs的微信第三方平台认证授权流程

需要解决的问题 微信的第三方开发者平台采用的是OAuth的认证流程。因此,需要解决的问题是: 按照OAuth的流程,调用微信第三方平台的api来获取preauthenticatioincode 等参数,提供授权页面让...

奔走在IT路上 ⋅ 2016/04/21 ⋅ 0

Up to 9% off rs2 gold for Ninja update 9.8-9.18,Ready to gain?

If you looking for massive amounts of storage, you in luck! The Corsair Obsidian buy cheap runescape gold 900D was built with you in mind. The 900D comes with three hard drive c......

happiesgress ⋅ 2017/09/06 ⋅ 0

g1 fullgc时间超长到时服务超时

如题,full gc导致服务停止响应,大神帮忙分析分析~ Java HotSpot(TM) 64-Bit Server VM (25.60-b23) for linux-amd64 JRE (1.8.060-b27), built on Aug 4 2015 12:19:40 by "javare" with ......

Itdotaer ⋅ 2017/07/09 ⋅ 2

Train Herblore Level with 9% off 500M runescape gold shop on RSorder 8.19-8.24

When an employer conducts a background rs3 gold check on their own they will usually only get a hold of information on the location held, dates associated with employment and in......

happiesgress ⋅ 2016/08/22 ⋅ 0

Save 8% cost on runescape 07 gold with code RSOD8 Until Dec. 5 for smite

The concentrated noise of people talking is deafening. I rs 2007 gold can make out some members of the Bali Nine. Andrew Chan is sitting in a prayer circle holding hands.. This ......

happiesgress ⋅ 2016/11/30 ⋅ 0

Gather Ghostweave for Ghostly&Up to 10% off best runescape gold on Rsorder Until 10.31

Coming soon: a co working space with desks available rs gold for $20/day. 425 15th Ave. 18. If given an Mute or Ban, you may continue playing on other accounts for the duration ......

happiesgress ⋅ 2017/10/26 ⋅ 0

mobile ios gold runescape with 6% off and 8% Bonus

It probably a bit late to interject get me started so let rs mobile android gold instead turn this ship 180 and say (mostly) nice things about a guy who came the other way in an......

happiesgress ⋅ 2017/12/28 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

JavaScript零基础入门——(八)JavaScript的数组

JavaScript零基础入门——(八)JavaScript的数组 欢迎大家回到我们的JavaScript零基础入门,上一节课我们讲了有关JavaScript正则表达式的相关知识点,便于大家更好的对字符串进行处理。这一...

JandenMa ⋅ 今天 ⋅ 0

sbt网络问题解决方案

转自:http://dblab.xmu.edu.cn/blog/maven-network-problem/ cd ~/.sbt/launchers/0.13.9unzip -q ./sbt-launch.jar 修改 vi sbt/sbt.boot.properties 增加一个oschina库地址: [reposit......

狐狸老侠 ⋅ 今天 ⋅ 0

大数据,必须掌握的10项顶级安全技术

我们看到越来越多的数据泄漏事故、勒索软件和其他类型的网络攻击,这使得安全成为一个热门话题。 去年,企业IT面临的威胁仍然处于非常高的水平,每天都会看到媒体报道大量数据泄漏事故和攻击...

p柯西 ⋅ 今天 ⋅ 0

Linux下安装配置Hadoop2.7.6

前提 安装jdk 下载 wget http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop-2.7.6/hadoop-2.7.6.tar.gz 解压 配置 vim /etc/profile # 配置java环境变量 export JAVA_HOME=/opt/jdk1......

晨猫 ⋅ 今天 ⋅ 0

crontab工具介绍

crontab crontab 是一个用于设置周期性被执行的任务工具。 周期性执行的任务列表称为Cron Table crontab(选项)(参数) -e:编辑该用户的计时器设置; -l:列出该用户的计时器设置; -r:删除该...

Linux学习笔记 ⋅ 今天 ⋅ 0

深入Java多线程——Java内存模型深入(2)

5. final域的内存语义 5.1 final域的重排序规则 1.对于final域,编译器和处理器要遵守两个重排序规则: (1)在构造函数内对一个final域的写入,与随后把这个被构造对象的引用赋值给一个引用...

江左煤郎 ⋅ 今天 ⋅ 0

面试-正向代理和反向代理

面试-正向代理和反向代理 Nginx 是一个高性能的反向代理服务器,但同时也支持正向代理方式的配置。

秋日芒草 ⋅ 今天 ⋅ 0

Spring 依赖注入(DI)

1、Setter方法注入: 通过设置方法注入依赖。这种方法既简单又常用。 类中定义set()方法: public class HelloWorldOutput{ HelloWorld helloWorld; public void setHelloWorld...

霍淇滨 ⋅ 昨天 ⋅ 0

马氏距离与欧氏距离

马氏距离 马氏距离也可以定义为两个服从同一分布并且其协方差矩阵为Σ的随机变量之间的差异程度。 如果协方差矩阵为单位矩阵,那么马氏距离就简化为欧氏距离,如果协方差矩阵为对角阵,则其也...

漫步当下 ⋅ 昨天 ⋅ 0

聊聊spring cloud的RequestRateLimiterGatewayFilter

序 本文主要研究一下spring cloud的RequestRateLimiterGatewayFilter GatewayAutoConfiguration @Configuration@ConditionalOnProperty(name = "spring.cloud.gateway.enabled", matchIfMi......

go4it ⋅ 昨天 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部