`*gddlZddlZddlZddlZddlZddlZddlZdadadZ ddZ dZ dZ dZ dZdZd Zd Zd Zd Zd ZdZdZdS)Nc"tjdd}d|dg}|D]A}tjtj|rdSBt dtjddS)NXDG_CONFIG_HOMEz ~/.configz~/.oscrcz /osc/oscrczJERROR: oscrc does not exist, please create one as explained in the README.) osenvirongetpathexists expanduserprintsysexit) configdirpathsr s M/home/osmocom-build/jenkins/workspace/Osmocom_OBS_sync/scripts/obs/lib/osc.py check_oscrcrs 0+>>I I111 2E 7>>"',,T22 3 3  FF   HQKKKKKcf|,d|vr&td|tjd|a|adS)N:z3ERROR: this doesn't look like a valid OBS project: r)r r rprojapiurl)urlobs_projs r set_apiurlrsG h   RRR S S S HQKKK FFFrct|tr-tr dtjtd|}n!d|}ntrddtg|z}ndg|z}t j|g|Ri|S)Nzosc -A  zosc oscz-A) isinstancestrrshlexquotelibrun_cmd)cmdargskwargss rrun_oscr'*s #s   7EK//77#77CC,,CC  $'#-CC'C-C ;s ,T , , ,V , ,,rctdttdtg}|jdS)NzOBS: getting packages in list )r rr'outputrstripsplit)rets rget_remote_pkgsr/=sL ,d , ,--- 64. ! !C :     $ $T * **rctjj}t|dt dt t j|g}|j dkrdS|j dD]}| }|dkrg|dkra| drK| dr6| d d  d d cS| d r%| d dddcSt|dt|ddS)Nz: getting OBS versionr)r*0masterzosmocom-mastercommit_z.txt_r.rz.dscz1: WARNING: failed to find package version on OBS!z": assuming the package is outdated)r"r%feedr r'rrr basenamer+r-r, startswithendswith)packager8r.lines rget_package_versionr>Csh 8=D W + + +,,, 64!1!1'!:!:; < zz z z apiz-XPUTz-T) r rr r9r"config path_tempropenwriter'unlink)r< path_meta path_meta_obsfs rcreate_packagerL^sY W 0 0 0111gw''G:'///I4d44W444M i    @'@@d@@@AAA -'---... /000                  UD%y- @AAAIis$A%CCCcXtjddtjjdgdS)Nrmz-rf/osc)r"r#rDrErrremove_temp_oscrQrs-Ku!5;;;<=====rcdt|dtj|}t j|}tjjd}|dtd|}ttj |tdt|g|tj |drtdd| t j d tj|d| td d| td d d|g|tdS)Nz: updating OBS packagerOr@checkout)cwdz/*zdel *T)shellrTzmv * zadd *commit-mz upgrade to )r rr r9r"get_output_pathrDrErrQmakedirsr'globr#r r!)r<version path_output path_temp_oscpath_temp_osc_pkgs rupdate_packager_vsY W , , ,---gw''G%g..Kz+111M(;;4;;';;K  Zw '];;;; y%)))**<t):;;;;K8 $56688!!!! G4%67777 Xt4744 5;LMMMMrc t|d|dtdd|ttj|gdS)Nz: removing from OBS ()rdeleterW)r r'rrr r9)r< commit_msgs rdelete_packagerdsP W 8 8: 8 8 8999 Yj$0@0@0I0I JKKKKKrcttdtjddtgj}t |d5}||ddddS#1swxYwYdS)Nz: getting prjconfmetaprjconfrAr rr"rr'r+rFrG) output_filerghs r get_prjconfrks T $ $ $%%%goovy$788?G k3  1 A77A;>A;c ttdtjddd|d|tgdS)Nz: updating prjconfrfrg-FrWr rr"rr') prjconf_filercs rupdate_prjconfrqsR T % % %&&&GOOV<: rcttdtjddtgj}t |d5}||ddddS#1swxYwYdS)Nz: getting metarfprjrArh)rirfrjs rget_metarts T ! ! !""" 7??FE40 1 1 8D k3  1  rlc ttdtjddd|d|tgdS)Nz: updating metarfrsrnrWro) meta_filercs r update_metarwsR T " " "###GOOV9: rctdtdtjdgjdS)NzOBS: getting list of projects (ralsr*)r rr"rr'r+r,r-rPrr get_projectsrzsO 5F 5 5 5666 7??D6 " " ) 0 0 2 2 8 8 > >>r)N)rZrr shutilr r" lib.configrrrrr'r/r>rLrQr_rdrkrqrtrwrzrPrrr}s7           ---&+++ 6(>>>6LLL ?????r