merged make_dir and make_missing_dir

This commit is contained in:
2020-05-05 18:40:10 +00:00
parent 83315e5476
commit c229ed59fa
4 changed files with 11 additions and 19 deletions
+1 -11
View File
@@ -4,6 +4,7 @@ from datetime import datetime
from collections import defaultdict
from jungfrau_utils.scripts.jungfrau_run_pedestals import run as ju_record_raw_pedestal
from slic.utils import make_missing_dir
TIMESTAMP_FORMAT = "%Y%m%d_%H%M"
@@ -78,17 +79,6 @@ def take_pedestal(instrument, pgroup, api_address, raw_dir, res_dir, analyze_loc
return res_file_base
def make_missing_dir(d):
if os.path.exists(d):
return
msg = "Directory \"{}\" does not exist, creating it...".format(d)
print(msg)
os.makedirs(d, exist_ok=True)
os.chmod(d, 0o775)
def analyze_pedestal_on_cluster(instrument, raw_file_base, res_dir, user=None):
pedestals_taken = raw_file_base + "*"
pedestals_taken = glob(pedestals_taken)
+3 -3
View File
@@ -1,7 +1,7 @@
import os
import colorama
from slic.utils import json_dump, make_dir
from slic.utils import json_dump, make_missing_dir
from slic.utils.printing import printable_dict
from slic.utils.ask_yes_no import ask_Yes_no
@@ -65,14 +65,14 @@ class ScanBackend:
def create_output_dirs(self):
make_dir(self.scan_info.base_dir)
make_missing_dir(self.scan_info.base_dir)
for acq in self.acquisitions:
default_dir = acq.default_dir
if default_dir is None:
continue
data_dir = default_dir + self.data_base_dir
make_dir(data_dir)
make_missing_dir(data_dir)
def get_filename(self, istep):
+1 -1
View File
@@ -3,7 +3,7 @@ from .utils import *
from .channels import Channels
from .config import Config
from .elog import Elog
from .fs_tools import can_create_file, glob_files, make_dir
from .fs_tools import can_create_file, glob_files, make_missing_dir
from .ipy_tools import devices
from .json_tools import json_dump
from .npy_tools import fraction_to_percentage, within, within_fraction, get_dtype, get_shape, is_array
+6 -4
View File
@@ -17,14 +17,16 @@ def can_create_file(filename):
return False
def make_dir(p):
def make_missing_dir(p):
p = Path(p)
if p.exists():
return
printable = p.absolute().as_posix()
print(f"Path \"{printable}\" does not exist, will try to create it...")
p.mkdir(parents=True)
p.chmod(0o775)
msg = "Directory \"{}\" does not exist, creating it...".format(printable)
print(msg)
p.mkdir(mode=0o775, parents=True, exist_ok=True)
def glob_files(folder, pattern):