|
5 | 5 | import json |
6 | 6 |
|
7 | 7 | def write_jupyterlab_config(): |
8 | | - config_jupyterlab = os.environ['JUPYTER_CONFIG_DIR'] |
9 | | - file_path = config_jupyterlab + '/jupyter_server_config.json' |
| 8 | + dir_config_jupyterlab = os.getenv('JUPYTER_CONFIG_DIR', |
| 9 | + os.path.join(os.getenv('HOME'), '.jupyter') |
| 10 | + ) |
| 11 | + file_server_config = os.path.join(dir_config_jupyterlab, 'jupyter_server_config.json') |
10 | 12 |
|
11 | | - if not os.path.isfile(file_path): |
12 | | - os.makedirs( config_jupyterlab + '/.jupyter/', exist_ok=True) |
13 | | - else: |
14 | | - config_file = open(file_path, 'r') |
15 | | - config_payload = config_file.read() |
16 | | - config_file.close() |
| 13 | + if not os.path.exists(dir_config_jupyterlab): |
| 14 | + os.makedirs( dir_config_jupyterlab, exist_ok=True) |
| 15 | + elif os.path.isfile(file_server_config) : |
| 16 | + with open(file_server_config, "r") as config_file: |
| 17 | + config_payload = config_file.read() |
17 | 18 |
|
18 | 19 | try: |
19 | 20 | config_json = json.loads(config_payload) |
@@ -93,7 +94,7 @@ def write_jupyterlab_config(): |
93 | 94 | "default_auth_type": os.getenv('RUCIO_DEFAULT_AUTH_TYPE', 'x509_proxy'), |
94 | 95 | } |
95 | 96 |
|
96 | | - config_file = open(file_path, 'w') |
| 97 | + config_file = open(file_server_config, 'w') |
97 | 98 | config_file.write(json.dumps(config_json, indent=2)) |
98 | 99 | config_file.close() |
99 | 100 |
|
@@ -121,6 +122,19 @@ def write_jupyterlab_config(): |
121 | 122 | # rucio_config['client'] = client_config |
122 | 123 | # with open('/opt/rucio/etc/rucio.cfg', 'w') as f: |
123 | 124 | # rucio_config.write(f) |
| 125 | + |
| 126 | +# [client] |
| 127 | +# rucio_host = https://vre-rucio.cern.ch |
| 128 | +# auth_host = https://vre-rucio-auth.cern.ch |
| 129 | +# ca_cert = /certs/rucio_ca.pem |
| 130 | +# account = garcia |
| 131 | +# auth_type = oidc |
| 132 | +# oidc_audience = rucio |
| 133 | +# oidc_polling = true |
| 134 | +# oidc_issuer = escape |
| 135 | +# oidc_scope = openid profile offline_access |
| 136 | +# auth_token_file_path = /tmp/rucio_oauth.token |
| 137 | + |
124 | 138 |
|
125 | 139 | if __name__ == '__main__': |
126 | 140 | write_jupyterlab_config() |
|
0 commit comments