TruxtonFileIO newrelation

From truxwiki.com
Revision as of 15:23, 21 May 2020 by Sam (talk | contribs) (Created page with "This create new relationship sourced from a file in Truxton. It automatically associates the parent file and media identifiers used in the Relation table....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This create new relationship sourced from a file in Truxton. It automatically associates the parent file and media identifiers used in the Relation table.

Syntax

object newlocation();

Return value

A Relation object

Sample

 1 import truxton
 2 
 3 def main():
 4   t = truxton.create()
 5   file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
 6 
 7   imsi = file.newartifact()
 8 
 9   imsi.type = truxton.ENTITY_TYPE_IMSI
10   imsi.value = "310120265624299"
11   imsi.datatype = truxton.DATA_TYPE_ASCII
12   imsi.length = 15
13   imsi.offset = 1
14   imsi.save()
15 
16   mac = file.newartifact()
17 
18   mac.type = truxton.ENTITY_TYPE_MAC_ADDRESS
19   mac.value = "001422012345"
20   mac.datatype = truxton.DATA_TYPE_ASCII
21   mac.length = 12
22   mac.offset = 111
23   mac.save()
24 
25   relationship = file.newrelation()
26 
27   relationship.a = imsi.id
28   relationship.b = mac.id
29   relationship.typea = truxton.OBJECT_TYPE_ENTITY
30   relationship.typeb = truxton.OBJECT_TYPE_ENTITY
31   relationship.relation = truxton.RELATION_RELATED
32 
33   if relationship.save() is True:
34     print( "New relationship established" )
35 
36 if __name__ == "__main__":
37   main()