U
    3d                     @   sD   d dl Z d dlZd dlmZmZ d dlZd dlZG dd deZdS )    N)ShellCommandget_tsc                   @   sB   e Zd ZdddZdddZdd Zd	d
 ZdddZdd ZdS )
ScriptBaseNc                 C   s8   t jddd| _| jj| _t | _|r4t j	| d S )NZInstancezinstance-iddefault)
botoconfiggetZinstance_id	__class____name__namer   tsread)selfconfig_file r   9/tmp/pip-unpacked-wheel-d7dsrkjd/boto/pyami/scriptbase.py__init__	   s
    
zScriptBase.__init__ c                 C   s   t j|| d S N)r   utilsnotify)r   subjectbodyr   r   r   r      s    zScriptBase.notifyc                 C   s<   t j|s8zt | W n   tjd|  Y nX d S )NzError creating directory: %s)ospathisdirmkdirr   logerrorr   r   r   r   r   r      s
    zScriptBase.mkdirc                 C   s   t j|r| d|  d S )Nz	umount %s)r   r   ismountrunr   r   r   r   umount   s    zScriptBase.umountTFc                 C   sd   t ||d| _| jjdkr\tjd|| jjf  |rN| dd|| jjf  |r\t	d | jjS )N)cwdr   z)Error running command: "%s". Output: "%s"zError encounteredz=Error running the following command:
	%s

Command output:
	%s)
r   Zlast_commandstatusr   r   r   outputr   sysexit)r   commandr   Zexit_on_errorr#   r   r   r   r!      s    

zScriptBase.runc                 C   s   d S r   r   )r   r   r   r   main*   s    zScriptBase.main)N)r   )TFN)	r
   
__module____qualname__r   r   r   r"   r!   r*   r   r   r   r   r      s   


r   )r   r'   Z
boto.utilsr   r   r   objectr   r   r   r   r   <module>   s
   