Created
August 18, 2020 06:14
-
-
Save michael-adam-sheehan/66e7a32aae5b237e662a381c40aa44f3 to your computer and use it in GitHub Desktop.
sfdc-errorlog-extraction-deletion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def delete(self): | |
print(f"Deleting logs from instance...") | |
if self.apexLogIds: | |
logIdsCsvFile = f"{self._logdir}/apex-logids.csv" | |
with open(logIdsCsvFile, 'w') as csvwriter_file: | |
csvwriter = csv.writer(csvwriter_file) | |
csvwriter.writerow(['Id']) | |
for id in self.apexLogIds: | |
csvwriter.writerow([id]) | |
sfdxCmd = f"sfdx force:data:bulk:delete -s ApexLog -w 5 -f {logIdsCsvFile} --targetusername={self.targetusername}" | |
try: | |
p = subprocess.Popen(sfdxCmd, shell=True, | |
stdout=subprocess.PIPE, encoding='utf-8') | |
p.wait() | |
result = p.communicate()[0].strip() | |
p.stdout.close() | |
print(f"{result}") | |
except: | |
e = sys.exc_info()[0] | |
print(f"Error deleting logs: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment