σ V°"`c@@s•dZddlmZddlmZddlmZddlmZddlmZm Z ddlm Z m Z d e fd „ƒYZ d „Zd S( utExternalStatus Class to store status and state information about repositories and create a string representation. i(tabsolute_import(tunicode_literals(tprint_functioni(t EMPTY_STR(tprintlogt indent_string(tVERBOSITY_VERBOSEtVERBOSITY_DUMPtExternalStatuscB@s‰eZdZdZdZdZdZdZdZdZ dZ dZ dZ d „Z d „Zd „Zd „Zd „Zd„Zd„ZRS(uClass to represent the status of a given source repository or tree. Individual repositories determine their own status in the Repository objects. This object is just resposible for storing the information and passing it up to a higher level for reporting or global decisions. There are two states of concern: * If the repository is in-sync with the externals description file. * If the repostiory working copy is clean and there are no pending transactions (e.g. add, remove, rename, untracked files). u-u?ueusuMu u!uocC@sL|j|_|j|_|j|_t|_t|_t|_t|_dS(N( tDEFAULTt sync_statet clean_statet source_typeRtpathtcurrent_versiontexpected_versiont status_output(tself((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pyt__init__.s      cC@s@|jƒ|tkr#|jƒn|tkr<|jƒndS(u8Write status message to the screen and log file N(t_default_status_messageRt_verbose_status_messageRt_dump_status_message(Rt verbosity((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pytlog_status_message7s     c C@s>djd|jd|jd|jd|jƒ}t|ƒdS(u7Return the default terse status message string u{sync}{clean}{src_type} {path}tsynctcleantsrc_typeR N(tformatR R R R R(Rtmsg((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pyR@s cC@sͺ|j}|j|jkr$d}n|j|jkr?d}ndj|jƒ}|j|jkr„djd|jd|jƒ}ndjd|d |ƒ}t|ƒd S( u1Return the verbose status message string u clean sandboxumodified sandboxuon {0}u{current} --> {expected}tcurrenttexpectedu {clean}, {sync}RRN( R R t STATUS_OKtDIRTYRRR RR(Rt clean_strtsync_strR((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pyRHs    cC@s t|jdƒ}t|ƒdS(u.Return the dump status message string i N(RRR(RR((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pyRXscC@smt}|jƒ}|s!t}nH|jtjkpB|jtjk}|ri|jtjkrit}qin|S(uπReport if it is safe to update a repository. Safe is defined as: * If a repository is empty, it is safe to update. * If a repository exists and has a clean working copy state with no pending transactions. (tFalsetexiststTrueR RRtMODEL_MODIFIEDR (Rtsafe_to_updatet repo_existst sync_safe((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pyR'^s    cC@sg|jtjk}|jtjkpE|jtjkpE|jtjk}|r]|r]t}nt}|S(uTDetermine if the repo exists. This is indicated by: * sync_state is not EMPTY * if the sync_state is empty, then the valid states for clean_state are default, empty or unknown. Anything else and there was probably an internal logic error. NOTE(bja, 2017-10) For the moment we are considering a sync_state of default or unknown to require user intervention, but we may want to relax this convention. This is probably a result of a network error or internal logic error but more testing is needed. (R RtEMPTYR R tUNKNOWNR#R%(Rtis_emptyt clean_validR$((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pyR$ys  (t__name__t __module__t__doc__R R+R*R&R Rt STATUS_ERRORtOPTIONALt STANDALONEtMANAGEDRRRRRR'R$(((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pyRs$    cC@s5t}x(|D] }||}||jƒM}q W|S(ukCheck if *ALL* repositories are in a safe state to update. We don't want to do a partial update of the repositories then die, leaving the model in an inconsistent state. Note: if there is an update to do, the repositories will by definiation be out of synce with the externals description, so we can't use that as criteria for updating. (R%R'(t tree_statusR'tcomptstat((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pytcheck_safe_to_update_repos•s   N(R0t __future__RRRtglobal_constantsRtutilsRRRRtobjectRR8(((sV/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/externals_status.pyts