ó
¼S]c           @@ s   d  Z  d d l m Z m Z d d l Z d d l m Z d d l m Z d d l	 m
 Z
 d d l m Z m Z d   Z d	   Z d
   Z d S(   sf   The ``run`` command executes a project, by default without asking questions (fails on missing config).i    (   t   absolute_importt   print_functionN(   t$   prepare_with_ui_mode_printing_errors(   t   load_project(   t   ProjectCommand(   t   create_bootstrap_envt   run_on_bootstrap_envc         C@ s   |  j  |  } | d  k r | d  k	 r t d |  j  } | j   j d  r[ | | d <n | g | d <t d | d |  } n  | S(   Nt   env_specs   .ipynbt   notebookt   argst   namet
   attributes(   t   command_for_namet   Nonet   dictt   default_env_spec_namet   lowert   endswithR   (   t   projectt   command_namet   commandt   attrs(    (    s@   lib/python2.7/site-packages/anaconda_project/internal/cli/run.pyt   _command_from_name   s    c   
      C@ s  t  |   } | j   rF | j   rF t d  t |  t |  nĖ d } t | |  } t | d | d | d | d | d | } | j	 r d S| j
 d k r» t d |  d	 t j nV y | j
 j   WnB t k
 r}	 t d
 d j | j
 j  |	 j f d	 t j n Xd S(   sJ   Run the project.

    Returns:
        Does not return if successful.
    s1   Project should be ran by bootstrap env... fixing.t   ui_modet   env_spec_nameR   t   extra_command_argst   environNs]   No known run command for project %s; try adding a 'commands:' section to anaconda-project.ymlt   files   Failed to execute '%s': %st    (   R   t   has_bootstrap_env_spect   is_running_in_bootstrap_envt   printR   R   R   R   R   t   failedt   command_exec_infot   syst   stderrt   execvpet   OSErrort   joinR	   t   strerror(
   t   project_dirR   t   conda_environmentR   R   R   R   R   t   resultt   e(    (    s@   lib/python2.7/site-packages/anaconda_project/internal/cli/run.pyt   run_command#   s6    

		"c         C@ s)   t  |  j |  j |  j |  j |  j  d S(   s3   Start the run command and return exit status code..i   (   R,   t	   directoryt   modeR   R   t   extra_args_for_command(   R	   (    (    s@   lib/python2.7/site-packages/anaconda_project/internal/cli/run.pyt   mainM   s    %(   t   __doc__t
   __future__R    R   R"   t/   anaconda_project.internal.cli.prepare_with_modeR   t*   anaconda_project.internal.cli.project_loadR   t!   anaconda_project.project_commandsR   t2   anaconda_project.internal.cli.environment_commandsR   R   R   R,   R0   (    (    (    s@   lib/python2.7/site-packages/anaconda_project/internal/cli/run.pyt   <module>   s   		*