a _qi~@sDddlZddlZddZddZddZdd Zd d Zd d ZdS)NcCs|ddkr|dkrdSdS)Nr"lineZisquotfrr-/usr/share/lve/modlscapi/user/exec_command.py first_quotsrcCs$|t|ddkr |dkr dSdS)Nrrr)lenrrrr last_quot sr cCs|d}d}d}g}tt|D]p}||dkr"t|||dkrRd}||}q"t|||dkrd}|d||7}||q"|||q"t|dS)N rr)splitranger rr appendprint)commandZisquotresresultirrr parse_commands"   rc Csg}zJtj|dtjtjd}|j}|s,qL|dkr||qWn4ty}zt dt |WYd}~n d}~00|S)NT)shellstdoutstderrr zCall process error: ) subprocessPopenPIPErreadlinestriprdecode Exceptionrstr)rrpoutputinstrrr exec_command's  &r$cCs t|S)z Run command via os.system and return its exit status :param command: Command to execute in a subshell :return: Exit status of the command process )ossystem)rrrrexec_command_out6sr'cCs&t|}|D]}||vr |Sq dS)N)r$)rZ substringrrrrrexec_command_find_substring@s  r))r%rrr rr$r'r)rrrrs