comments += "\nCircumstance: " + row["circumstance"] a.HiddenAnimalDetails = comments a.AnimalComments = getsbnotes(row["AnimalID"]) if row["euthanasiaType"] != "0": a.Archived = 1 a.DeceasedDate = a.DateBroughtIn a.PutToSleep = 1 a.PTSReasonID = 4 if row["crueltyCase"] == "TRUE": a.CrueltyCase = 1 a.LastChangedDate = getdate(row["AddDateTime"]) # Do we have a default image for this animal in the images folder and document table? if documents.has_key(row["AnimalID"]): imagedata = asm.load_image_from_file(documents[row["AnimalID"]]) if imagedata is not None: asm.animal_image(a.ID, imagedata) # tblperson.csv for row in asm.csv_to_list(PATH + "tblperson.csv"): o = asm.Owner() owners.append(o) ppo[row["recnum"]] = o o.OwnerTitle = row["Title"] o.OwnerForeNames = row["FirstName"] o.OwnerSurname = row["LastName"] o.OwnerName = o.OwnerForeNames + " " + o.OwnerSurname o.HomeTelephone = row["dep_HomePhone"] o.WorkTelephone = row["dep_WorkPhone"] o.MobileTelephone = row["dep_MobilePhone"] if addresses.has_key(row["physicalAddress"].strip()): a = addresses[row["physicalAddress"].strip()]
if row["STATUS"] == 2: a.DeceasedDate = a.DateBroughtIn a.PTSReasonID = 2 # Died # Does this animal have an image? If so, add media/dbfs entries for it if PICTURE_IMPORT: imdata = None if os.path.exists(PATH + "/images/%s.jpg" % row["ANIMALKEY"]): f = open(PATH + "/images/%s.jpg" % row["ANIMALKEY"], "rb") imdata = f.read() f.close() elif os.path.exists(PATH + "/images/%s.JPG" % row["ANIMALKEY"]): f = open(PATH + "/images/%s.JPG" % row["ANIMALKEY"], "rb") imdata = f.read() f.close() if imdata is not None: asm.animal_image(a.ID, imdata) # Vaccinations if VACCINATION_IMPORT: for row in cvacc: if not ppa.has_key(row["ANIMALKEY"]): continue a = ppa[row["ANIMALKEY"]] # Each row contains a vaccination av = asm.AnimalVaccination() animalvaccinations.append(av) vaccdate = row["VACCEFFECT"] if vaccdate is None: vaccdate = a.DateBroughtIn av.AnimalID = a.ID av.VaccinationID = 8 if row["VACCTYPE"].find("DHLPP") != -1: av.VaccinationID = 8
if row["STATUS"] == 2: a.DeceasedDate = a.DateBroughtIn a.PTSReasonID = 2 # Died # Does this animal have an image? If so, add media/dbfs entries for it if IMAGE_FILE_IMPORT: imdata = None if os.path.exists(PATH + "/images/%s.jpg" % row["ANIMALKEY"]): f = open(PATH + "/images/%s.jpg" % row["ANIMALKEY"], "rb") imdata = f.read() f.close() elif os.path.exists(PATH + "/images/%s.JPG" % row["ANIMALKEY"]): f = open(PATH + "/images/%s.JPG" % row["ANIMALKEY"], "rb") imdata = f.read() f.close() if imdata is not None: asm.animal_image(a.ID, imdata) # Vaccinations if VACCINATION_IMPORT: for row in cvacc: if row["ANIMALKEY"] not in ppa: continue a = ppa[row["ANIMALKEY"]] # Each row contains a vaccination av = asm.AnimalVaccination() animalvaccinations.append(av) vaccdate = getdate(row["VACCEFFECTIVEDATE"]) if vaccdate is None: vaccdate = a.DateBroughtIn av.AnimalID = a.ID av.VaccinationID = 8 if row["VACCTYPE"].find("DHLPP") != -1: av.VaccinationID = 8
a.DeceasedDate = dd a.Archived = 1 elif di.startswith("Euthanized"): a.PutToSleep = 1 a.PTSReasonID = 2 a.DeceasedDate = dd a.Archived = 1 # Does this animal have an image? If so, add media/dbfs entries for it if PICTURE_IMPORT: imdata = None for i in range(0, 3): fname = "%s/%s-%s.jpg" % (PICTURES, a.ShelterCode, i) if os.path.exists(fname): with open(fname, "rb") as f: asm.animal_image(a.ID, f.read()) # Run back through the animals, if we have any that are still # on shelter after 1 year, add an adoption to an unknown owner # asm.adopt_older_than(animals, movements, uo.ID, 365) # Now that everything else is done, output stored records for a in animals: print a for o in owners: print o for m in movements: print m asm.stderr_summary(animals=animals, owners=owners, movements=movements)
comments = "Original breed: " + breed1 + "/" + breed2 comments += ", Color: " + color1 + "/" + color2 comments += ", Status: " + status comments += ", Area: " + location + ", Pen: " + pen a.HiddenAnimalDetails = comments # All animals are non-shelter until we find them in the intake list a.NonShelterAnimal = 1 a.Archived = 1 # Read and store images asm.stderr("Process images") for row in canimalimages: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] asm.animal_image( a.ID, asm.load_image_from_file("%s/images/%s" % (PATH, row["ImageFilename"]))) # microchips, animal codes and document ids asm.stderr("Process animal ID numbers") for row in canimalids: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] # TODO: These can be customer specific, but appear to be default/fixed 2 == microchip if row["sysAnimalIDTypesID"] == "2": a.IdentichipNumber = row["Code"] a.Identichipped = 1 a.IdentichipDate = asm.getdate_mmddyy(row["LastUpdate"]) # 10 = police document id if row["sysAnimalIDTypesID"] == "10": asm.additional_field("DocumentID", 0, a.ID, row["Code"])
if row["sysAnimalStatusChoicesID"] == "15": a.DeceasedDate = a.DateBroughtIn a.PutToSleep = 0 a.PTSReasonID = 2 a.Archived = 1 comments = "Original breed: " + breed1 + "/" + breed2 comments += ", Color: " + color1 + "/" + color2 comments += ", Status: " + status comments += ", Area: " + location + ", Pen: " + pen a.HiddenAnimalDetails = comments # Read and store images for row in canimalimages: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] asm.animal_image(a.ID, asm.load_image_from_file("%s/images/%s" % (PATH, row["ImageFilename"]))) # microchips, animal codes and document ids for row in canimalids: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] # TODO: These are customer specific. 2 == microchip if row["sysAnimalIDTypesID"] == "2": a.IdentichipNumber = row["Code"] a.Identichipped = 1 a.IdentichipDate = asm.getdate_mmddyy(row["LastUpdate"]) # 10 = police document id if row["sysAnimalIDTypesID"] == "10": asm.additional_field("DocumentID", 0, a.ID, row["Code"]) # 21 = jcas animal code if row["sysAnimalIDTypesID"] == "21" and row["Code"].strip() != "":