Ejemplo n.º 1
0
def upload_to_pacs(path, anonymize=False):
    all_dcms = [get_all_dcms_inside_dir(dir, checking=True, anonymize=True) for dir in get_all_sub_dirs(path)] if anonymize else \
               [get_all_dcms_inside_dir(dir, checking=True) for dir in get_all_sub_dirs(path)]
    pacs_dict = read_json('pacs.json')
    pacs_lis = [Orthanc(k, v) for k, v in pacs_dict.items()]
    N = len(pacs_dict.keys())
    pacs_names = ['pacs' + str(n) for n in range(N)]
    for i, pacs in enumerate(pacs_lis):
        t = time()
        for dir_dcms in all_dcms:
            upload_folder(pacs, pacs_names[i], dir_dcms)
        print("Takes {} secs to upload to {}".format((time() - t),
                                                     pacs_names[i]))
Ejemplo n.º 2
0
    def FromConfig(cls, path):
        """Creates a client from a config file.

        A configuration file is a plain python file which creates a client
        called "cl" in its local namespace.
        """
        # if path is a module
        if hasattr(path, '__file__'):
            path = os.path.splitext(path.__file__)[0] + '.py'

        for d in utils.get_all_sub_dirs(path)[::-1]:
            sys.path.insert(0, d)
        cf = {'sys':sys}; execfile(path, cf, cf)
        return cf['cl']
Ejemplo n.º 3
0
 def FromConfig(cls, path):
     """Creates a client from a config file.
     
     A configuration file is a plain python file which creates a client 
     called "cl" in its local namespace.
     The configuration file may be passed as a module or as path to the 
     configuration file.
     """
     if isinstance(path, types.ModuleType):
         reload(path)
         return path.cl
     import sys, utils
     for d in utils.get_all_sub_dirs(path)[::-1]:
         sys.path.insert(0, d)
     cf = {'sys':sys}; execfile(path, cf, cf)
     return cf['cl']
Ejemplo n.º 4
0
    def FromConfig(cls, path):
        """Creates a client from a config file.

        A configuration file is a plain python file which creates a client
        called "cl" in its local namespace.
        """
        # if path is a module
        if hasattr(path, '__file__'):
            path = os.path.splitext(path.__file__)[0] + '.py'

        for d in utils.get_all_sub_dirs(path)[::-1]:
            sys.path.insert(0, d)
        cf = {
            'sys': sys
        }
        execfile(path, cf, cf)
        return cf['cl']
Ejemplo n.º 5
0
 def FromConfig(cls, path):
     """Creates a client from a config file.
     
     A configuration file is a plain python file which creates a client 
     called "cl" in its local namespace.
     The configuration file may be passed as a module or as path to the 
     configuration file.
     """
     if isinstance(path, types.ModuleType):
         reload(path)
         return path.cl
     import sys, utils
     for d in utils.get_all_sub_dirs(path)[::-1]:
         sys.path.insert(0, d)
     cf = {
         'sys': sys
     }
     execfile(path, cf, cf)
     return cf['cl']
Ejemplo n.º 6
0
def mp_uploading(path):
    all_dcms = [
        get_all_dcms_inside_dir(dir, checking=True)
        for dir in get_all_sub_dirs(path)
    ]
    pacs_dict = read_json('pacs.json')
    pacs_lis = [Orthanc(k, v) for k, v in pacs_dict.items()]
    N = len(pacs_dict.keys())
    pacs_names = ['pacs' + str(n) for n in range(N)]
    p = Pool(5)
    for i, pacs in enumerate(pacs_lis):
        t = time()
        p.apply_async(
            upload_folder,
            zip(
                len(all_dcms) * [pacs],
                len(all_dcms) * [pacs_names[i]], all_dcms))
        print("Takes {} secs to upload to {}".format((time() - t),
                                                     pacs_names[i]))