99
1010import re
1111import subprocess
12+ from typing import Optional
13+ from pathlib import Path
1214
1315
14- def run_command (command , shell = False , rval = False ):
16+ def run_command (
17+ command : str , rval : bool = False
18+ ) -> Optional [subprocess .CompletedProcess ]:
1519 """
1620 Run a subprocess command and return the result object
1721 Inputs:
1822 - command, str with command to run
1923 Outputs:
2024 - result object from subprocess.run
2125 """
22- if not shell :
23- command = command .split ()
26+ command = command .split ()
2427 result = subprocess .run (
2528 command ,
2629 capture_output = True ,
2730 text = True ,
2831 timeout = 300 ,
29- shell = shell ,
32+ shell = True ,
3033 check = False ,
3134 )
3235 if result .returncode :
@@ -38,7 +41,9 @@ def run_command(command, shell=False, rval=False):
3841 return result
3942
4043
41- def clone_repo_mirror (source , repo_ref , parent , mirror_loc , loc ):
44+ def clone_repo_mirror (
45+ source : str , repo_ref : str , parent : str , mirror_loc : Path , loc : Path
46+ ) -> None :
4247 """
4348 Clone a repo source using a local git mirror.
4449 Assume the mirror is set up as per the Met Office
@@ -71,7 +76,7 @@ def clone_repo_mirror(source, repo_ref, parent, mirror_loc, loc):
7176 run_command (command )
7277
7378
74- def clone_repo (repo_source , repo_ref , loc ) :
79+ def clone_repo (repo_source : str , repo_ref : str , loc : Path ) -> None :
7580 """
7681 Clone the repo and checkout the provided ref
7782 Only if a remote source
@@ -84,7 +89,7 @@ def clone_repo(repo_source, repo_ref, loc):
8489 run_command (command )
8590
8691
87- def sync_repo (repo_source , repo_ref , loc ) :
92+ def sync_repo (repo_source : str , repo_ref : str , loc : Path ) -> None :
8893 """
8994 Rsync a local git clone and checkout the provided ref
9095 """
0 commit comments