Difference between revisions of "TruxtonEnumeration"

From truxwiki.com
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This class lets you enumerate things in Truxton.
 
This class lets you enumerate things in Truxton.
 
=Attributes and Methods=
 
=Attributes and Methods=
==<code>addnote(text: str) -> boolean</code>==
 
This adds an investigator's note.
 
The <code>text</code> parameter is the contents of the note.
 
It will return
 
[https://docs.python.org/3.10/library/constants.html?highlight=false#True True] if the tag was associated with the communication, [https://docs.python.org/3.10/library/constants.html?highlight=false#False False] on failure.
 
The note is stored in the <code>[InvestigatorNote]</code> table in the database.
 
 
 
==<code>currentfile: [[TruxtonFileIO]]</code>==
 
==<code>currentfile: [[TruxtonFileIO]]</code>==
 
The [[TruxtonFileIO|file]] that contained whatever is being enumerated.
 
The [[TruxtonFileIO|file]] that contained whatever is being enumerated.
Line 16: Line 9:
 
==<code>currentmedia: [[TruxtonMedia]]</code>==
 
==<code>currentmedia: [[TruxtonMedia]]</code>==
 
The [[TruxtonMedia|media]] that contained whatever is being enumerated.
 
The [[TruxtonMedia|media]] that contained whatever is being enumerated.
 +
 +
==<code>reset() -> None</code>==
 +
Rewinds the enumeration to the beginning.
  
 
==<code>scope: int</code>==
 
==<code>scope: int</code>==
Line 33: Line 29:
 
* [[Type_Camera_Information]] - The enumeration will be [[TruxtonEXIF]] objects
 
* [[Type_Camera_Information]] - The enumeration will be [[TruxtonEXIF]] objects
 
* [[Type_Event]] - The enumeration will be [[TruxtonEvent]] objects
 
* [[Type_Event]] - The enumeration will be [[TruxtonEvent]] objects
* [[Type_File]] - The enumeration will be [[TruxtonFileIO]] objects
+
* Type_File - The enumeration will be [[TruxtonFileIO]] objects
 
* [[Type_Investigation]] - The enumeration will be [[TruxtonInvestigation]] objects
 
* [[Type_Investigation]] - The enumeration will be [[TruxtonInvestigation]] objects
 
* [[Type_Location]] - The enumeration will be [[TruxtonLocation]] objects
 
* [[Type_Location]] - The enumeration will be [[TruxtonLocation]] objects
 
* [[Type_Media]] - The enumeration will be [[TruxtonMedia]] objects
 
* [[Type_Media]] - The enumeration will be [[TruxtonMedia]] objects
* [[Type_Message_Attachment]] - The enumeration will be [[TruxtonFileIO]] objects of message attachments
+
* Type_Message_Attachment - The enumeration will be [[TruxtonFileIO]] objects of message attachments
* [[Type_Message_Body]] - The enumeration will be [[TruxtonFileIO]] objects of message bodies
+
* Type_Message_Body - The enumeration will be [[TruxtonFileIO]] objects of message bodies
* [[Type_Participant]] - The enumeration will be [[TruxtonMessageParticipant]] objects
+
* Type_Participant - The enumeration will be [[TruxtonMessageParticipant]] objects
 
* [[Type_Website_Visit]] - The enumeration will be [[TruxtonUrl]] objects
 
* [[Type_Website_Visit]] - The enumeration will be [[TruxtonUrl]] objects
  
Line 45: Line 41:
 
This sample will enumerate all of the investigations in Truxton and list all media in those investigations.
 
This sample will enumerate all of the investigations in Truxton and list all media in those investigations.
 
The output is [http://en.wikipedia.org/wiki/JSON JSON] format.
 
The output is [http://en.wikipedia.org/wiki/JSON JSON] format.
 +
There is a more complete example on [https://github.com/SammyB428/Truxton-Samples/blob/main/Scripts/Enumerate.py GitHub].
  
<source lang="Python" highlight="59-61,63,68,72">
+
<source lang="Python" highlight="62-65,73-74">
 
import sys
 
import sys
 
import json
 
import json
Line 74: Line 71:
 
  object_name["investigation"] = d;
 
  object_name["investigation"] = d;
 
  print(json.dumps(object_name, ensure_ascii = False, sort_keys = True))
 
  print(json.dumps(object_name, ensure_ascii = False, sort_keys = True))
 +
 +
return None
  
 
def output_media(media: truxton.TruxtonMedia) -> None:
 
def output_media(media: truxton.TruxtonMedia) -> None:
Line 100: Line 99:
 
  object_name["media"] = d;
 
  object_name["media"] = d;
 
  print("," + json.dumps(object_name, ensure_ascii = False, sort_keys = True))
 
  print("," + json.dumps(object_name, ensure_ascii = False, sort_keys = True))
 +
 +
return None
  
 
def dump_investigation(investigation: truxton.TruxtonInvestigation, instance: int) -> None:
 
def dump_investigation(investigation: truxton.TruxtonInvestigation, instance: int) -> None:
Line 112: Line 113:
 
   output_media(media)
 
   output_media(media)
  
def main():
+
return None
 +
 
 +
def main() -> None:
 
  investigations = trux.newenumerator()
 
  investigations = trux.newenumerator()
 
  investigations.target = truxton.Type_Investigation
 
  investigations.target = truxton.Type_Investigation
Line 122: Line 125:
 
   instance += 1
 
   instance += 1
 
  print("]")
 
  print("]")
 +
 +
return None
 +
 +
if __name__ == "__main__":
 +
sys.exit(main())
 +
</source>
 +
 +
=Media Sample=
 +
This sample will enumerate all of the events in a piece of media.
 +
 +
<source lang="Python" highlight="8,10-12">
 +
import sys
 +
sys.path.append('C:/Program Files/Truxton/SDK')
 +
import truxton
 +
 +
def main():
 +
trux = truxton.create()
 +
 +
events = trux.newenumerator()
 +
 +
events.target = truxton.Type_Event
 +
events.scope = truxton.Type_Media
 +
events.scopeid = "30e6b5bb-9d61-b5cc-bfe3-b05d67a29110"
 +
 +
for event in events:
 +
  print( event.title + " - " + F"{event.start:%Y-%m-%dT%H:%M:%SZ}" + " - " + event.description)
 +
 +
return None
  
 
if __name__ == "__main__":
 
if __name__ == "__main__":
  main()
+
  sys.exit(main())
 
</source>
 
</source>

Latest revision as of 07:33, 23 October 2025

This class lets you enumerate things in Truxton.

Attributes and Methods

currentfile: TruxtonFileIO

The file that contained whatever is being enumerated.

currentinvestigation: TruxtonInvestigation

The investigation that contained whatever is being enumerated.

currentmedia: TruxtonMedia

The media that contained whatever is being enumerated.

reset() -> None

Rewinds the enumeration to the beginning.

scope: int

This sets the level at which things can be enumerated. The default is a global scope, you want to enumerate everything in Truxton. You can set it to:

  • Type_Investigation - This will tell Truxton you wish to enumerate things in a particular investigation
  • Type_Media - This will tell Truxton you wish to enumerate things in a particular piece of media

scopeid: str | UUID

This isolates the scope to the particular investigation or media you wish to enumerate.

target: int

These are the things you want to enumerate. It can be one of the following:

Sample

This sample will enumerate all of the investigations in Truxton and list all media in those investigations. The output is JSON format. There is a more complete example on GitHub.

import sys
import json
sys.path.append('C:/Program Files/Truxton/SDK')
import truxton

trux = truxton.create()

media_status_names = json.loads(trux.mediastatusnames())
media_type_names = json.loads(trux.mediatypenames())

def output_investigation(investigation: truxton.TruxtonInvestigation, instance: int) -> None:
 if instance > 0:
  print(",")

 d = dict()
 d["id"] = investigation.id.lower()
 d["name"] = investigation.name
 d["case"] = investigation.case
 d["description"] = investigation.description
 d["jurisdiction"] = str(investigation.jurisdiction)
 d["opened"] = F"{investigation.opened:%Y-%m-%dT%H:%M:%SZ}"
 d["status"] = str(investigation.status)
 d["type"] = str(investigation.type)

 object_name = dict()
 object_name["investigation"] = d;
 print(json.dumps(object_name, ensure_ascii = False, sort_keys = True))

 return None

def output_media(media: truxton.TruxtonMedia) -> None:
 d = dict()
 d["id"] = media.id.lower()
 d["name"] = media.name
 d["case"] = media.case
 d["loadconfiguration"] = str(media.configid)
 d["created"] = F"{media.created:%Y-%m-%dT%H:%M:%SZ}"
 d["description"] = media.description
 d["evidencebag"] = media.evidencebag
 d["expires"] = F"{media.expires:%Y-%m-%dT%H:%M:%SZ}"
 d["generatedfolderid"] = media.generatedfolderid.lower()
 d["latitude"] = str(media.latitude)
 d["longitude"] = str(media.longitude)
 d["originator"] = media.originator
 d["percentcomplete"] = str(media.percentcomplete)
 d["rootid"] = media.rootid.lower()
 d["status"] = str(media.status)
 d["statusname"] = media_status_names[str(media.status)]
 d["type"] = str(media.type)
 d["typename"] = media_type_names[str(media.type)]
 d["updated"] = F"{media.updated:%Y-%m-%dT%H:%M:%SZ}"

 object_name = dict()
 object_name["media"] = d;
 print("," + json.dumps(object_name, ensure_ascii = False, sort_keys = True))

 return None

def dump_investigation(investigation: truxton.TruxtonInvestigation, instance: int) -> None:
 output_investigation(investigation, instance)

 investigation_media = trux.newenumerator()
 investigation_media.scope = truxton.Type_Investigation
 investigation_media.scopeid = investigation.id
 investigation_media.target = truxton.Type_Media

 for media in investigation_media:
  output_media(media)

 return None

def main() -> None:
 investigations = trux.newenumerator()
 investigations.target = truxton.Type_Investigation

 print("[")
 instance = 0
 for investigation in investigations:
  dump_investigation(investigation, instance)
  instance += 1
 print("]")

 return None

if __name__ == "__main__":
 sys.exit(main())

Media Sample

This sample will enumerate all of the events in a piece of media.

import sys
sys.path.append('C:/Program Files/Truxton/SDK')
import truxton

def main():
 trux = truxton.create()

 events = trux.newenumerator()
 
 events.target = truxton.Type_Event
 events.scope = truxton.Type_Media
 events.scopeid = "30e6b5bb-9d61-b5cc-bfe3-b05d67a29110"
 
 for event in events:
  print( event.title + " - " + F"{event.start:%Y-%m-%dT%H:%M:%SZ}" + " - " + event.description)

 return None

if __name__ == "__main__":
 sys.exit(main())