@@ -85,6 +85,7 @@ def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defa
85
85
self ._iscomponent = False
86
86
self ._confs_to_load = []
87
87
self ._confstoparent = []
88
+ self .configTree = None
88
89
89
90
# save a folder details, and return the new folder instance
90
91
def _savefolder ( self , parent , fname , folderuri ):
@@ -517,9 +518,11 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
517
518
logger .debug ( f"Loading configs { self ._confs_to_load = } , { stopatnameoruri = } " )
518
519
# load configurations
519
520
# 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 )
521
523
result = False
522
-
524
+
525
+ # now load configs
523
526
while True :
524
527
if verbose :
525
528
print ( "." ,end = "" )
@@ -632,11 +635,11 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
632
635
if parentnode is None :
633
636
# do this one later
634
637
self ._confstoparent .append ( ( thisnode , theparent_u ) )
635
- # print( f"Saved for later {confstoparent [-1]=}" )
638
+ # print( f"\nSaved for later {self._confstoparent [-1]=}" )
636
639
else :
637
640
# parent is known so attach to it
638
641
thisnode .parent = parentnode
639
- # print( f"Config {conftitle} Added config {thisconfu} parent={parentnode}" )
642
+ # print( f"\nConfig {conftitle} Added config {thisconfu} parent={parentnode}" )
640
643
# now check if stopatnameoururi is present and if so set result True
641
644
if result :
642
645
break
@@ -648,20 +651,26 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
648
651
newconfstoparent = []
649
652
for (i ,nodedetails ) in enumerate (self ._confstoparent ):
650
653
(node ,theparent_u ) = nodedetails
654
+ # print( f"\n{node=} {theparent_u=}" )
651
655
# if we find the parent, attach it - if not found, add it to this list of those still needing parent
652
656
parentnode = anytree .search .find ( self .configTree , filter_ = lambda n : n .name == theparent_u )
653
657
if parentnode :
654
658
# found!
655
659
node .parent = parentnode
656
660
foundparent = True
657
- # print( f"Parented {node}" )
661
+ # print( f"\nParented {node=} {theparent_u }" )
658
662
else :
659
663
# remember this still needs parenting! Will be found on a later pass UNLESS it's been tried a few times and always fails
660
664
# in which case we'll print a message and ignore the config!
661
665
newconfstoparent .append ( (node ,theparent_u ) )
666
+ # print( f"\npostponing {node=} {theparent_u}" )
667
+ # print( f"tree= {anytree.RenderTree(self.configTree, style=anytree.AsciiStyle())}" )
668
+
662
669
self ._confstoparent = newconfstoparent
670
+ # if no parent was found on this run through confstoparent, give up with the confs to parent preserved
663
671
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 } " )
665
674
break
666
675
667
676
if verbose :
@@ -671,12 +680,12 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
671
680
672
681
def load_configtree ( self , * , fromconfig_u = None , loadbaselines = False , followsubstreams = False , loadchangesets = False , alwayscaching = False ):
673
682
# 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=}" )
677
686
if not fromconfig_u :
678
687
fromconfig_u = self .configTree .children [0 ].name
679
- print ( f"{ fromconfig_u = } " )
688
+ # print( f"{fromconfig_u=}" )
680
689
startnode = anytree .search .find ( self .configTree , filter_ = lambda n : n .name == fromconfig_u )
681
690
682
691
for conf in anytree .iterators .preorderiter .PreOrderIter ( startnode ):
@@ -693,7 +702,7 @@ def load_configtree( self, *, fromconfig_u=None, loadbaselines=False, followsubs
693
702
if not loadbaselines :
694
703
continue
695
704
696
- print ( f"------------------------------\n '{ conf .title } ' { conf .ismutable = } { conf .created } { conf .name } " )
705
+ # print( f"------------------------------\n'{conf.title}' {conf.ismutable=} {conf.created} {conf.name}" )
697
706
# print( f"{conf.children=}" )
698
707
self .set_local_config (conf .name )
699
708
# continue
@@ -766,6 +775,7 @@ def get_local_config(self, name_or_uri, global_config_uri=None, verbose=False, i
766
775
result = cu
767
776
if result is None :
768
777
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
769
779
break
770
780
# print( f"GLC {result} {self=} {name_or_uri=}" )
771
781
@@ -1146,12 +1156,12 @@ def create_changeset( self, name, noexception=False ):
1146
1156
# create the changeset - it's up to the caller to select it as current config
1147
1157
# get the current stream
1148
1158
stream_x = self .execute_get_rdf_xml ( self .local_config )
1149
- print ( f"{ stream_x = } " )
1159
+ # print( f"{stream_x=}" )
1150
1160
# find the changesets URL
1151
1161
cs_u = rdfxml .xmlrdf_get_resource_uri ( stream_x , ".//rm_config:changesets" )
1152
1162
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=}" )
1155
1165
# create a new CS by POST
1156
1166
body = f"""<rdf:RDF
1157
1167
xmlns:dcterms="http://purl.org/dc/terms/"
@@ -1197,12 +1207,12 @@ def deliver_changeset( self ):
1197
1207
cs_x = self .execute_get_rdf_xml ( self .local_config )
1198
1208
stream_u = rdfxml .xmlrdf_get_resource_uri ( cs_x , './/oslc_config:overrides' )
1199
1209
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=}" )
1202
1212
# find the delivery session factory
1203
1213
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=}" )
1206
1216
# create the content
1207
1217
body = f"""<rdf:RDF
1208
1218
xmlns:dcterms="http://purl.org/dc/terms/"
@@ -1228,31 +1238,31 @@ def deliver_changeset( self ):
1228
1238
ds_u = location
1229
1239
else :
1230
1240
raise Exception ( f"Unknown response { response .status_code } " )
1231
- print ( f"{ ds_u = } " )
1241
+ # print( f"{ds_u=}" )
1232
1242
1233
1243
# deliver it by first retrieving the delivery session then putting it back with a different state
1234
1244
ds_x = self .execute_get_rdf_xml ( ds_u )
1235
1245
# set rm_config:deliverySessionState to rm_config:delivered
1236
1246
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" )=}' )
1241
1251
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()=}" )
1243
1253
# PUT the new state to start delivery
1244
1254
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 )
1245
1255
location = response .headers .get ('Location' )
1246
1256
if response .status_code == 200 :
1247
1257
state = rdfxml .xmlrdf_get_resource_uri ( response , ".//rm_config:deliverySessionState" )
1248
- print ( f"{ state = } " )
1258
+ # print( f"{state=}" )
1249
1259
elif response .status_code == 202 :
1250
1260
# wait for the tracker to finished
1251
1261
result = self .wait_for_tracker ( location , interval = 1.0 , progressbar = True , msg = f"Waiting for changeset delivery to complete" )
1252
1262
if result is None :
1253
1263
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) )
1256
1266
state = rdfxml .xmlrdf_get_resource_uri ( result , './/oslc_auto:verdict ' )
1257
1267
else :
1258
1268
raise Exception ( f"Unknown response { response .status_code } " )
0 commit comments