parse_database_credentials()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 15
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
#!/usr/bin/env python3
0 ignored issues
show
Bug introduced by
There seems to be a cyclic import (db_sync_tool.remote.utility -> db_sync_tool.utility.helper).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.remote.system -> db_sync_tool.utility.mode).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.recipes.wordpress -> db_sync_tool.utility.system -> db_sync_tool.utility.parser).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.helper -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.system -> db_sync_tool.utility.helper -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.utility.mode -> db_sync_tool.utility.output).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.utility.helper -> db_sync_tool.utility.output -> db_sync_tool.utility.log -> db_sync_tool.utility.system).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.utility.helper -> db_sync_tool.utility.system).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.utility.helper -> db_sync_tool.utility.mode).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.recipes.laravel -> db_sync_tool.utility.system -> db_sync_tool.utility.parser).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.mode -> db_sync_tool.utility.helper -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.utility.helper -> db_sync_tool.utility.output -> db_sync_tool.utility.mode).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.remote.utility -> db_sync_tool.utility.mode -> db_sync_tool.utility.system -> db_sync_tool.utility.helper).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.utility.validation).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.system -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.utility.helper -> db_sync_tool.utility.output -> db_sync_tool.utility.system).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.mode -> db_sync_tool.remote.system -> db_sync_tool.remote.client -> db_sync_tool.utility.helper -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.utility.helper -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.mode -> db_sync_tool.remote.system -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.utility.helper -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.database.utility -> db_sync_tool.utility.mode -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.utility.helper -> db_sync_tool.remote.utility).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.utility.helper -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.utility.parser).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.recipes.symfony -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.utility.parser).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.recipes.typo3 -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.utility.parser).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (db_sync_tool.recipes.drupal -> db_sync_tool.utility.output -> db_sync_tool.utility.system -> db_sync_tool.utility.parser).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
2
# -*- coding: future_fstrings -*-
3
4
"""
5
Drupal script
6
"""
7
8
import json
9
from db_sync_tool.utility import mode, system, helper, output
10
11
12
def check_configuration(client):
13
    """
14
    Checking Drupal database configuration with Drush
15
    :param client: String
16
    :return:
17
    """
18
    _path = system.config[client]['path']
19
20
    # Check Drush version
21
    _raw_version = mode.run_command(
22
        f'{helper.get_command(client, "drush")} status --fields=drush-version --format=string '
23
        f'-r {_path}',
24
        client,
25
        True
26
    )
27
28
    output.message(
29
        output.host_to_subject(client),
30
        f'Drush version: {_raw_version}',
31
        True
32
    )
33
34
    stdout = mode.run_command(
35
        f'{helper.get_command(client, "drush")} core-status --pipe '
36
        f'--fields=db-hostname,db-username,db-password,db-name,db-port '
37
        f'-r {_path}',
38
        client,
39
        True
40
    )
41
42
    _db_config = parse_database_credentials(json.loads(stdout))
43
44
    system.config[client]['db'] = helper.clean_db_config(_db_config)
45
46
47
def parse_database_credentials(db_credentials):
48
    """
49
    Parsing database credentials to needed format
50
    :param db_credentials: Dictionary
51
    :return: Dictionary
52
    """
53
    _db_config = {
54
        'name': db_credentials['db-name'],
55
        'host': db_credentials['db-hostname'],
56
        'password': db_credentials['db-password'],
57
        'port': db_credentials['db-port'],
58
        'user': db_credentials['db-username'],
59
    }
60
61
    return _db_config
62