@@ -675,7 +675,11 @@ def safe_encode(x):
675
675
return pm .Literal ("Unknown" , pm .XSD ['string' ])
676
676
if isinstance (x , (str , unicode )):
677
677
if os .path .exists (x ):
678
- return pm .URIRef ('file://%s%s' % (getfqdn (), x ))
678
+ try :
679
+ return pm .URIRef ('file://%s%s' % (getfqdn (), x ))
680
+ except AttributeError :
681
+ return pm .Literal ('file://%s%s' % (getfqdn (), x ),
682
+ pm .XSD ['anyURI' ])
679
683
else :
680
684
return pm .Literal (x , pm .XSD ['string' ])
681
685
if isinstance (x , (int ,)):
@@ -1085,8 +1089,7 @@ def write_provenance(self, results, filename='provenance', format='turtle'):
1085
1089
g .add_namespace (dcterms )
1086
1090
g .add_namespace (nipype )
1087
1091
1088
- a0_attrs = {foaf ["host" ]: pm .URIRef (runtime .hostname ),
1089
- nipype ['module' ]: self .__module__ ,
1092
+ a0_attrs = {nipype ['module' ]: self .__module__ ,
1090
1093
nipype ["interface" ]: classname ,
1091
1094
pm .PROV ["label" ]: classname ,
1092
1095
nipype ['duration' ]: safe_encode (runtime .duration ),
@@ -1095,6 +1098,12 @@ def write_provenance(self, results, filename='provenance', format='turtle'):
1095
1098
nipype ['platform' ]: safe_encode (runtime .platform ),
1096
1099
nipype ['version' ]: safe_encode (runtime .version ),
1097
1100
}
1101
+ try :
1102
+ a0_attrs [foaf ["host" ]] = pm .URIRef (runtime .hostname )
1103
+ except AttributeError :
1104
+ a0_attrs [foaf ["host" ]] = pm .Literal (runtime .hostname ,
1105
+ pm .XSD ['anyURI' ])
1106
+
1098
1107
try :
1099
1108
a0_attrs .update ({nipype ['command' ]: safe_encode (runtime .cmdline )})
1100
1109
a0_attrs .update ({nipype ['command_path' ]: safe_encode (runtime .command_path )})
0 commit comments