mirror of https://github.com/MISP/PyMISP
Merge pull request #402 from SteveClement/feedGenRedis_fix
fix: [perms] Added try/except for various permission conditions, also…pull/405/head
commit
409ee532ba
|
@ -1,15 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
import datetime
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
import redis
|
||||
|
||||
import settings
|
||||
|
||||
from generator import FeedGenerator
|
||||
|
||||
|
||||
|
@ -60,7 +60,10 @@ class RedisToMISPFeed:
|
|||
except Exception as error:
|
||||
self.save_error_to_redis(error, data)
|
||||
|
||||
beautyful_sleep(5, self.format_last_action())
|
||||
try:
|
||||
beautyful_sleep(5, self.format_last_action())
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(130)
|
||||
|
||||
def pop(self, key):
|
||||
popped = self.serv.rpop(key)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import datetime
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import hashlib
|
||||
import datetime
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
|
||||
|
@ -142,9 +142,24 @@ class FeedGenerator:
|
|||
|
||||
# Manifest
|
||||
def _init_manifest(self):
|
||||
# check if outputdir exists and try to create it if not
|
||||
if not os.path.exists(settings.outputdir):
|
||||
try:
|
||||
os.makedirs(settings.outputdir)
|
||||
except PermissionError as error:
|
||||
print(error)
|
||||
print("Please fix the above error and try again.")
|
||||
sys.exit(126)
|
||||
|
||||
# create an empty manifest
|
||||
with open(os.path.join(settings.outputdir, 'manifest.json'), 'w'):
|
||||
pass
|
||||
try:
|
||||
with open(os.path.join(settings.outputdir, 'manifest.json'), 'w'):
|
||||
pass
|
||||
except PermissionError as error:
|
||||
print(error)
|
||||
print("Please fix the above error and try again.")
|
||||
sys.exit(126)
|
||||
|
||||
# create new event and save manifest
|
||||
self.create_daily_event()
|
||||
|
||||
|
|
Loading…
Reference in New Issue