Get our daemon script path.
27
def get_manager_cmd(self):
        """"""
        cmd = os.path.abspath(os.path.join(os.path.dirname(__file__), "server", "notebook_daemon.py"))
        assert os.path.exists(cmd)
        return cmd
273351
def _get_ericscript_path(self):
        
        es = utils.which(os.path.join(utils.get_bcbio_bin(), self.EXECUTABLE))
        return os.path.dirname(os.path.realpath(es))
336106
def get_spyder_pythonpath(self):
        """"""
        active_path = [p for p in self.path if p not in self.not_active_path]
        return active_path + self.project_path
1321387
def get_program_path():
    """"""

    src_folder = os.path.dirname(__file__)
    program_path = os.sep.join(src_folder.split(os.sep)[:-1]) + os.sep

    return program_path
743584
def script(self):
        """"""
        self.shebang_header = self.shebang_headers[self.language]
        self.slurm_header   = [self.slurm_headers[k]['tag'] % v for k,v in self.slurm_params.items()]
        self.script_header  = self.script_headers[self.language]
        self.script_footer  = self.script_footers[self.language]
        return '\n'.join(flatter([self.shebang_header,
                                  self.slurm_header,
                                  self.script_header,
                                  self.command,
                                  self.script_footer]))
540108
def assert_script_in_current_directory():
  """"""

  script = sys.argv[0]
  assert os.path.abspath(os.path.dirname(script)) == os.path.abspath(
    '.'), f"Change into directory of script {script} and run again."
743141
def get_pidpath(rundir, process_type, name=None):
    
    assert rundir, "rundir is not configured"
    path = os.path.join(rundir, '%s.pid' % process_type)
    if name:
        path = os.path.join(rundir, '%s.%s.pid' % (process_type, name))
    log.log('common', 'get_pidpath for type %s, name %r: %s'
            % (process_type, name, path))
    return path
981230
def get_module_path(module):
    """"""
    return pathlib.Path(
        os.path.dirname(os.path.abspath(inspect.getfile(module))))
114349
def getdaemondebug(self):
        
        debugout = self.file_grep(r"^(daemon.*)\s+(\/var\/log\/.*)",
                                  *self.files)
        for i in debugout:
            return i[1]
254776
def _syspath(dev):
    '''
    
    '''
    dev = _devbase(dev)
    dev = re.sub(r'^([vhs][a-z]+)([0-9]+)', r'\1/\1\2', dev)

    # name = re.sub(r'^([a-z]+)(?<!(bcache|md|dm))([0-9]+)', r'\1/\1\2', name)
    return os.path.join('/sys/block/', dev)
599316
def caller_path(steps=1):
    """"""
    frame = sys._getframe(steps + 1)

    try:
        path = os.path.dirname(frame.f_code.co_filename)
    finally:
        del frame

    if not path:
        path = os.getcwd()

    return os.path.realpath(path)
1218932
def relpath(self):
        
        here = os.path.abspath(os.path.curdir)
        relpath = os.path.relpath(self.fpath, here)
        return relpath
107369
def _find_script(script_name):
    
    if os.path.isfile(script_name):
        return script_name
    path = os.getenv('PATH', os.defpath).split(os.pathsep)
    for dir in path:
        if dir == '':
            continue
        fn = os.path.join(dir, script_name)
        if os.path.isfile(fn):
            return fn

    print >> sys.stderr, 'Could not find script {0}'.format(script_name)
    raise SystemExit(1)
13158
def get_pidfile_path(working_dir):
   
   pid_filename = virtualchain_hooks.get_virtual_chain_name() + ".pid"
   return os.path.join( working_dir, pid_filename )
108609
def relpath(self, current_file, rel_path):
        
        script_dir = os.path.dirname(os.path.abspath(current_file))
        rel_path = os.path.abspath(os.path.join(script_dir, rel_path))
        return rel_path
946550
def script_dir(pyobject, follow_symlinks=True):
    
    if getattr(sys, 'frozen', False):  # py2exe, PyInstaller, cx_Freeze
        path = abspath(sys.executable)
    else:
        path = inspect.getabsfile(pyobject)
    if follow_symlinks:
        path = realpath(path)
    return dirname(path)
309526
def _get_destination(script_parts):
    """"""
    for part in script_parts:
        if part not in {'ln', '-s', '--symbolic'} and os.path.exists(part):
            return part