| Conditions | 4 |
| Total Lines | 19 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | # coding: utf-8 |
||
| 9 | def install(services_dir: str, package: str): |
||
| 10 | from os.path import isdir |
||
| 11 | from urllib.parse import urlparse |
||
| 12 | |||
| 13 | url = '{}/services-{}.git'.format(__github_url__, package) |
||
| 14 | if urlparse(package).scheme != '': |
||
| 15 | url = package |
||
| 16 | |||
| 17 | dest = '{}/{}'.format(services_dir, package) |
||
| 18 | if isdir(dest): |
||
| 19 | msg = 'Package "{}" is already installed'.format(package) |
||
| 20 | return False, msg |
||
| 21 | |||
| 22 | from git import Repo, exc |
||
| 23 | try: |
||
| 24 | Repo.clone_from(url, dest) |
||
| 25 | return True, None |
||
| 26 | except exc.GitCommandError as error: |
||
| 27 | return False, "Couldn't clone {} ({})".format(url, error) |
||
| 28 | |||
| 47 |