Beispiel #1
0
def get_command_line():
    from xia2.Handlers.CommandLine import CommandLine

    CommandLine.print_command_line()

    if not CommandLine.get_xinfo():
        # write an xinfo file then
        xinfo = os.path.join(os.getcwd(), "automatic.xinfo")

        argv = CommandLine.get_argv()

        if not CommandLine.get_directory():

            directories = []

            for arg in argv:
                if os.path.isdir(arg):
                    directories.append(os.path.abspath(arg))

            if not directories and not CommandLine.get_hdf5_master_files():
                raise Sorry(
                    "No image directory found in command line arguments. "
                    "Run xia2 without any options for command line help."
                )

        else:
            directories = CommandLine.get_directory()

        directories = [os.path.abspath(d) for d in directories]
        from xia2.Applications.xia2setup import write_xinfo

        check_hdf5_master_files(CommandLine.get_hdf5_master_files())

        if CommandLine.get_template() or CommandLine.get_hdf5_master_files():
            write_xinfo(
                xinfo,
                directories,
                template=CommandLine.get_template(),
                hdf5_master_files=CommandLine.get_hdf5_master_files(),
            )
        else:
            write_xinfo(xinfo, directories)

        CommandLine.set_xinfo(xinfo)

    return CommandLine
Beispiel #2
0
def run():
    streams_off()

    # test to see if sys.argv[-2] + path is a valid path - to work around
    # spaced command lines

    argv = CommandLine.get_argv()

    if not CommandLine.get_directory():

        directories = []

        for arg in argv:
            if os.path.isdir(arg):
                directories.append(os.path.abspath(arg))

        if not directories:
            raise RuntimeError('directory not found in arguments')

    else:
        directories = [CommandLine.get_directory()]

    directories = [os.path.abspath(d) for d in directories]

    # perhaps move to a new directory...
    settings = PhilIndex.get_python_object().xia2.settings
    crystal = settings.crystal

    with open(os.path.join(os.getcwd(), 'automatic.xinfo'), 'w') as fout:
        start = os.path.abspath(os.getcwd())
        directory = os.path.join(os.getcwd(), crystal, 'setup')
        try:
            os.makedirs(directory)
        except OSError as e:
            if not 'File exists' in str(e):
                raise e
        os.chdir(directory)

        rummage(directories)
        print_sweeps(fout)