Mercurial > hg > orthanc-tests
comparison PerfsDb/ConfigFileBuilder.py @ 156:f1a75985caa8
first Db test framework - work in progress
author | am@osimis.io |
---|---|
date | Thu, 16 Aug 2018 17:13:32 +0200 |
parents | |
children | df1f9946571c |
comparison
equal
deleted
inserted
replaced
155:e0996602b306 | 156:f1a75985caa8 |
---|---|
1 import typing | |
2 import json | |
3 | |
4 from DbType import DbType | |
5 | |
6 class ConfigFileBuilder: | |
7 | |
8 @staticmethod | |
9 def generate( | |
10 outputPath: str, | |
11 plugins: typing.List[str], | |
12 storagePath: str, | |
13 dbType: DbType, | |
14 dbSize: str, | |
15 port: int | |
16 ): | |
17 | |
18 config = {} | |
19 config["Plugins"] = plugins | |
20 config["StorageDirectory"] = storagePath | |
21 | |
22 dbConfig = {} | |
23 dbConfig["EnableIndex"] = True | |
24 dbConfig["Host"] = "127.0.0.1" | |
25 dbConfig["Lock"] = False | |
26 dbConfig["Port"] = port | |
27 | |
28 if dbType == DbType.MySQL: | |
29 dbConfig["EnableStorage"] = False | |
30 dbConfig["Database"] = "orthanc" | |
31 dbConfig["Username"] = "orthanc" | |
32 dbConfig["Password"] = "orthanc" | |
33 | |
34 config["MySQL"] = dbConfig | |
35 | |
36 elif dbType == DbType.PG9 or dbType == DbType.PG10: | |
37 dbConfig["EnableStorage"] = False | |
38 dbConfig["Database"] = "orthanc" | |
39 dbConfig["Username"] = "orthanc" | |
40 dbConfig["Password"] = "orthanc" | |
41 | |
42 config["PostgreSQL"] = dbConfig | |
43 | |
44 elif dbType == DbType.MSSQL: | |
45 dbConfig["ConnectionString"] = "Driver={ODBC Driver 13 for SQL Server};Server=tcp:index," + port + ";Database=master;Uid=sa;Pwd=MyStrOngPa55word!;Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30" | |
46 dbConfig["LicenseString"] = "1abaamBcReVXv6EtE_X___demo-orthanc%osimis.io___HHHnqVHYvEkR3jGs2Y3EvpbxZgTt7yaCniJa2Bz7hFWTMa" # note: this is a trial license expiring on 2018-09-30, replace with your license code | |
47 | |
48 config["MSSQL"] = dbConfig | |
49 | |
50 elif DbType == DbType.Sqlite: | |
51 config["IndexDirectory"] = storagePath | |
52 | |
53 else: | |
54 raise NotImplementedError | |
55 | |
56 with open(outputPath, "w") as configFile: | |
57 json.dump(config, fp=configFile, indent=4) |