@@ -85,6 +85,7 @@ def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defa
8585 self ._iscomponent = False
8686 self ._confs_to_load = []
8787 self ._confstoparent = []
88+ self .configTree = None
8889
8990 # save a folder details, and return the new folder instance
9091 def _savefolder ( self , parent , fname , folderuri ):
@@ -517,9 +518,11 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
517518 logger .debug ( f"Loading configs { self ._confs_to_load = } , { stopatnameoruri = } " )
518519 # load configurations
519520 # and build a tree with initial baseline as root, alternating baseline and stream nodes each with a list of children, so it can be walked if needed
520- self .configTree = anytree .AnyNode (name = 'theroot' ,title = 'root' , created = None , typesystem = None , ismutable = False , ischangeset = False )
521+ if not incremental or not self .configTree :
522+ self .configTree = anytree .AnyNode (name = 'theroot' ,title = 'root' , created = None , typesystem = None , ismutable = False , ischangeset = False )
521523 result = False
522-
524+
525+ # now load configs
523526 while True :
524527 if verbose :
525528 print ( "." ,end = "" )
@@ -632,11 +635,11 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
632635 if parentnode is None :
633636 # do this one later
634637 self ._confstoparent .append ( ( thisnode , theparent_u ) )
635- # print( f"Saved for later {confstoparent [-1]=}" )
638+ # print( f"\nSaved for later {self._confstoparent [-1]=}" )
636639 else :
637640 # parent is known so attach to it
638641 thisnode .parent = parentnode
639- # print( f"Config {conftitle} Added config {thisconfu} parent={parentnode}" )
642+ # print( f"\nConfig {conftitle} Added config {thisconfu} parent={parentnode}" )
640643 # now check if stopatnameoururi is present and if so set result True
641644 if result :
642645 break
@@ -648,20 +651,26 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
648651 newconfstoparent = []
649652 for (i ,nodedetails ) in enumerate (self ._confstoparent ):
650653 (node ,theparent_u ) = nodedetails
654+ # print( f"\n{node=} {theparent_u=}" )
651655 # if we find the parent, attach it - if not found, add it to this list of those still needing parent
652656 parentnode = anytree .search .find ( self .configTree , filter_ = lambda n : n .name == theparent_u )
653657 if parentnode :
654658 # found!
655659 node .parent = parentnode
656660 foundparent = True
657- # print( f"Parented {node}" )
661+ # print( f"\nParented {node=} {theparent_u }" )
658662 else :
659663 # remember this still needs parenting! Will be found on a later pass UNLESS it's been tried a few times and always fails
660664 # in which case we'll print a message and ignore the config!
661665 newconfstoparent .append ( (node ,theparent_u ) )
666+ # print( f"\npostponing {node=} {theparent_u}" )
667+ # print( f"tree= {anytree.RenderTree(self.configTree, style=anytree.AsciiStyle())}" )
668+
662669 self ._confstoparent = newconfstoparent
670+ # if no parent was found on this run through confstoparent, give up with the confs to parent preserved
663671 if not foundparent :
664- print ( f"Postponing potentially unparentable configs { self ._confstoparent } " )
672+ if verbose :
673+ print ( f"\n Postponing potentially unparentable configs { self ._confstoparent } " )
665674 break
666675
667676 if verbose :
@@ -671,12 +680,12 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
671680
672681 def load_configtree ( self , * , fromconfig_u = None , loadbaselines = False , followsubstreams = False , loadchangesets = False , alwayscaching = False ):
673682 # show the config tree
674- print ( f"tree= { anytree .RenderTree (self .configTree , style = anytree .AsciiStyle ())} " )
675- print ( f"{ self .configTree = } " )
676- print ( f"{ self .configTree .children = } " )
683+ # print( f"tree= {anytree.RenderTree(self.configTree, style=anytree.AsciiStyle())}" )
684+ # print( f"{self.configTree=}" )
685+ # print( f"{self.configTree.children=}" )
677686 if not fromconfig_u :
678687 fromconfig_u = self .configTree .children [0 ].name
679- print ( f"{ fromconfig_u = } " )
688+ # print( f"{fromconfig_u=}" )
680689 startnode = anytree .search .find ( self .configTree , filter_ = lambda n : n .name == fromconfig_u )
681690
682691 for conf in anytree .iterators .preorderiter .PreOrderIter ( startnode ):
@@ -693,7 +702,7 @@ def load_configtree( self, *, fromconfig_u=None, loadbaselines=False, followsubs
693702 if not loadbaselines :
694703 continue
695704
696- print ( f"------------------------------\n '{ conf .title } ' { conf .ismutable = } { conf .created } { conf .name } " )
705+ # print( f"------------------------------\n'{conf.title}' {conf.ismutable=} {conf.created} {conf.name}" )
697706# print( f"{conf.children=}" )
698707 self .set_local_config (conf .name )
699708 # continue
@@ -766,6 +775,7 @@ def get_local_config(self, name_or_uri, global_config_uri=None, verbose=False, i
766775 result = cu
767776 if result is None :
768777 if not self .load_configs ( stopatnameoruri = name_or_uri , verbose = verbose , incremental = incremental ):
778+ # config not found - give up (if found, this loops back to scan for the config again
769779 break
770780# print( f"GLC {result} {self=} {name_or_uri=}" )
771781
@@ -1146,12 +1156,12 @@ def create_changeset( self, name, noexception=False ):
11461156 # create the changeset - it's up to the caller to select it as current config
11471157 # get the current stream
11481158 stream_x = self .execute_get_rdf_xml ( self .local_config )
1149- print ( f"{ stream_x = } " )
1159+ # print( f"{stream_x=}" )
11501160 # find the changesets URL
11511161 cs_u = rdfxml .xmlrdf_get_resource_uri ( stream_x , ".//rm_config:changesets" )
11521162 comp_u = rdfxml .xmlrdf_get_resource_uri ( stream_x , './/oslc_config:component' )
1153- print ( f"{ cs_u = } " )
1154- print ( f"{ comp_u = } " )
1163+ # print( f"{cs_u=}" )
1164+ # print( f"{comp_u=}" )
11551165 # create a new CS by POST
11561166 body = f"""<rdf:RDF
11571167 xmlns:dcterms="http://purl.org/dc/terms/"
@@ -1197,12 +1207,12 @@ def deliver_changeset( self ):
11971207 cs_x = self .execute_get_rdf_xml ( self .local_config )
11981208 stream_u = rdfxml .xmlrdf_get_resource_uri ( cs_x , './/oslc_config:overrides' )
11991209 csname = rdfxml .xmlrdf_get_resource_text ( cs_x , './/dcterms:title' )
1200- print ( f"target { stream_u = } " )
1201- print ( f"cs name { csname = } " )
1210+ # print( f"target {stream_u=}" )
1211+ # print( f"cs name {csname=}" )
12021212 # find the delivery session factory
12031213 ds_f_u = self .get_factory_uri ("rm_config:DeliverySession" )
1204- print ( f"{ ds_f_u = } " )
1205- print ( f"{ self .services_uri = } " )
1214+ # print( f"{ds_f_u=}" )
1215+ # print( f"{self.services_uri=}" )
12061216 # create the content
12071217 body = f"""<rdf:RDF
12081218 xmlns:dcterms="http://purl.org/dc/terms/"
@@ -1228,31 +1238,31 @@ def deliver_changeset( self ):
12281238 ds_u = location
12291239 else :
12301240 raise Exception ( f"Unknown response { response .status_code } " )
1231- print ( f"{ ds_u = } " )
1241+ # print( f"{ds_u=}" )
12321242
12331243 # deliver it by first retrieving the delivery session then putting it back with a different state
12341244 ds_x = self .execute_get_rdf_xml ( ds_u )
12351245 # set rm_config:deliverySessionState to rm_config:delivered
12361246 state_x = rdfxml .xml_find_element ( ds_x , ".//rm_config:deliverySessionState" )
1237- print ( f"{ state_x = } " )
1238- print ( f"{ state_x .items ()= } " )
1239- print ( f'{ rdfxml .tag_to_uri ("rdf:resource" )= } ' )
1240- print ( f'{ rdfxml .tag_to_uri ( "rm_config:delivered" )= } ' )
1247+ # print( f"{state_x=}" )
1248+ # print( f"{state_x.items()=}" )
1249+ # print( f'{rdfxml.tag_to_uri("rdf:resource")=}' )
1250+ # print( f'{rdfxml.tag_to_uri( "rm_config:delivered" )=}' )
12411251 state_x .set (rdfxml .uri_to_tag ("rdf:resource" ), rdfxml .tag_to_uri ( "rm_config:delivered" ) )
1242- print ( f"{ state_x .items ()= } " )
1252+ # print( f"{state_x.items()=}" )
12431253 # PUT the new state to start delivery
12441254 response = self .execute_post_rdf_xml ( ds_u , data = ds_x ,headers = {'Content-Type' : 'application/rdf+xml' , 'OSLC-Core-Version' :'2.0' }, intent = "Start the delivery" , put = True )
12451255 location = response .headers .get ('Location' )
12461256 if response .status_code == 200 :
12471257 state = rdfxml .xmlrdf_get_resource_uri ( response , ".//rm_config:deliverySessionState" )
1248- print ( f"{ state = } " )
1258+ # print( f"{state=}" )
12491259 elif response .status_code == 202 :
12501260 # wait for the tracker to finished
12511261 result = self .wait_for_tracker ( location , interval = 1.0 , progressbar = True , msg = f"Waiting for changeset delivery to complete" )
12521262 if result is None :
12531263 raise Exception ( f"No result from tracker!" )
1254- print ( f"{ result = } " )
1255- print ( ET .tostring (result ) )
1264+ # print( f"{result=}" )
1265+ # print( ET.tostring(result) )
12561266 state = rdfxml .xmlrdf_get_resource_uri ( result , './/oslc_auto:verdict ' )
12571267 else :
12581268 raise Exception ( f"Unknown response { response .status_code } " )
0 commit comments