Difference between revisions of "TruxtonSensitiveSiteList"

From truxwiki.com
Jump to navigation Jump to search
Line 30: Line 30:
  
 
=Sample=
 
=Sample=
<source lang="Python" highlight="3-10">
+
<source lang="Python" line highlight="7-11,13,14,16,17">
def add_subject():
+
import sys
  t = truxton.create()
+
sys.path.append('C:/Program Files/Truxton/SDK')
  s = t.newsubject()
+
import truxton
  s.id = "00138955-133D-D2C1-A9E9-ADFF27FA80F4"
 
  s.name = "Alexander Downer"
 
  s.description = "Australian High Commissioner to the United Kingdom."
 
  s.birthday = ticks("1951-09-09T00:00:00-00:00")
 
  s.picture = b64(SUPPORT_DOCUMENTS_FOLDER + "Images/Alexander Downer.png")
 
  s.save()
 
  s.tag("AUS", "Australia - Friendly Foreign Government", truxton.TAG_ORIGIN_HUMAN)
 
  return
 
  
def b64(filename):
+
def main():
  with open( filename, "rb" ) as input_file:
+
t = truxton.create()
    data = input_file.read()
+
ssl = t.newsensitivesitelist()
    return str(base64.b64encode(data))[2:-1]
+
ssl.id = "43434343-4443-4343-4343-434343434343"
 +
ssl.name = "Test SSV"
 +
ssl.description = "The description of the test SSV"
 +
ssl.save()
 +
 
 +
ssl.add(39.136001, -77.701114, 100, "Lothar's")
 +
ssl.add(39.137793, -77.692892, 100, "Chik", "A30BE334-56B3-42FD-8860-92F74D47C9CC")
 +
 
 +
ssl.remove(39.136001, -77.701114, 100, "Lothar's")
 +
ssl.delete()
 +
 
 +
if __name__ == "__main__":
 +
    main()
 
</source>
 
</source>

Revision as of 17:02, 29 May 2021

This class lets you add list of geographic coordinates that should be alerted on. This will populate the [SensitiveSiteList] table in the database.

Attributes and Methods

description

A description of the list. This corresponds to the [Description] column of the [SensitiveSiteList] table.

id

This is the GUID of the list. This corresponds to the [ID] column of the [SensitiveSiteList] table.

name

The name of the list. This corresponds to the [Name] column of the [SensitiveSiteList] table.

add(wgs84_latitude, wgs84_longitude, distance_in_meters, name, optional_id)

This adds a location to the current list.

delete()

Deletes the list from Truxton. It will remove records from the [SensitiveSite] and [SensitiveSiteList] table.

remove(wgs84_latitude, wgs84_longitude, distance_in_meters, name)

This removes an item from the list.

save()

This will commit the information to the [SensitiveSiteList] table. It will return True if the record was saved to the database, False if there was an error.

Sample

 1 import sys
 2 sys.path.append('C:/Program Files/Truxton/SDK')
 3 import truxton
 4 
 5 def main():
 6  t = truxton.create()
 7  ssl = t.newsensitivesitelist()
 8  ssl.id = "43434343-4443-4343-4343-434343434343"
 9  ssl.name = "Test SSV"
10  ssl.description = "The description of the test SSV"
11  ssl.save()
12 
13  ssl.add(39.136001, -77.701114, 100, "Lothar's")
14  ssl.add(39.137793, -77.692892, 100, "Chik", "A30BE334-56B3-42FD-8860-92F74D47C9CC")
15 
16  ssl.remove(39.136001, -77.701114, 100, "Lothar's")
17  ssl.delete()
18 
19 if __name__ == "__main__":
20     main()