B
    &©‘_ä
  ã               @   sŽ   d dl Z d dlZd dlZd dlmZ d dlZd dlmZ d dlm	Z	 d dl
Z
d dlmZ d dlZe d¡Ze ej¡ e	ƒ ZG dd„ dƒZdS )	é    N)Ú	Namespace)Úmake_run_list)ÚPathFind)Úmessage_rsmasZ
matplotlibc               @   s   e Zd Zdd„ Zdd„ ZdS )Ú	CreateRunc             C   sJ  |j | _ |j| _|jdkr&|jd | _tj | j tj¡| _	tj | j tj
¡| _|| _|j| j_g | _x”|jD ]Š}|dkr˜|j| dkrö| j d| ¡ ql|dkrÊ| j d| ¡ | j d |j| ¡¡ ql|j| rl| j d| ¡ | j |j| ¡ qlW t ¡ }xB|d D ]6}tj tj |j |¡¡rt tj |j |¡¡ qW d S )	NÚtopsztopsStack.workflow)ÚuseGPUÚrmFilterÚnofocusÚzeroZapplyWaterMask)ÚTrueTz--)ÚbboxÚ	swath_numz"{}"r   )Úwork_dirÚprefixÚtemplateÚworkflowÚosÚpathÚjoinÚpathObjÚgeoreferencedirZgeo_reference_dirÚ	minopydirZ
minopy_dirÚinpsÚcustom_template_fileÚcommand_optionsÚStack_templateÚappendÚformatÚisce_clean_listÚisdirÚshutilÚrmtree)Úselfr   ÚitemZ
clean_list© r%   ú=/home/centos/operations/rsmas_insar/minsar/utils/stack_run.pyÚ__init__   s0    


zCreateRun.__init__c             C   s¢   | j dkr6t | jdd | j¡ ¡ dd | j¡ }n*t | jdd | j¡ ¡ dd | j¡ }t d¡}t|ƒ t	j
|dd	 ¡ }|d
k	r”tdƒ‚|tjd< d S )Nr   zstackSentinel.py ú z:export PATH=$ISCE_STACK/topsStack:$PATH; stackSentinel.py zstackStripMap.py z>export PATH=$ISCE_STACK/stripmapStack:$PATH; stackStripMap.py ÚPATHT)Úshellr   zERROR in create_runfiles.py)r   r   Úlogr   r   r   r   ÚgetenvÚprintÚ
subprocessÚPopenÚwaitÚ	ExceptionÚenviron)r#   ÚcmdZsystem_pathÚstatusr%   r%   r&   Úrun_stack_workflow8   s    


zCreateRun.run_stack_workflowN)Ú__name__Ú
__module__Ú__qualname__r'   r5   r%   r%   r%   r&   r      s   r   )r   Úsysr.   Úargparser   r!   Úminsar.utils.process_utilitiesr   Úminsar.objects.auto_defaultsr   Ú
contextlibÚminsar.objectsr   ZloggingZ	getLoggerZ
mpl_loggerZsetLevelZWARNINGr   r   r%   r%   r%   r&   Ú<module>   s   
