os.rename(tempname, destination)
-def populate_files(config_dir, config_files, uid, gid):
- # type: (str, Dict, int, int) -> None
+def populate_files(
+ config_dir: str, config_files: Dict, uid: int, gid: int
+) -> None:
"""create config files for different services"""
for fname in config_files:
config_file = os.path.join(config_dir, fname)
os.chown(file_path, uid, gid)
-def write_tmp(s, uid, gid):
- # type: (str, int, int) -> IO[str]
+def write_tmp(s: str, uid: int, gid: int) -> IO[str]:
tmp_f = tempfile.NamedTemporaryFile(mode='w', prefix='ceph-tmp')
os.fchown(tmp_f.fileno(), uid, gid)
tmp_f.write(s)
os.chown(os.path.join(dirpath, filename), uid, gid)
-def read_file(path_list, file_name=''):
- # type: (List[str], str) -> str
+def read_file(path_list: List[str], file_name: str = '') -> str:
"""Returns the content of the first file found within the `path_list`
:param path_list: list of file paths to search
return 'Unknown'
-def pathify(p):
- # type: (str) -> str
+def pathify(p: str) -> str:
p = os.path.expanduser(p)
return os.path.abspath(p)
-def get_file_timestamp(fn):
- # type: (str) -> Optional[str]
+def get_file_timestamp(fn: str) -> Optional[str]:
try:
mt = os.path.getmtime(fn)
return datetime.datetime.fromtimestamp(