Skip to content

Commit

Permalink
opt send virus email command and other
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexCXC committed Sep 6, 2024
1 parent d177d05 commit 567d092
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dtable_events/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def create_db_tables(config):
Base.metadata.create_all(engine)


def prepare_db_tables(seafile_config):
def prepare_seafile_tables(seafile_config):
# reflect the seafile_db tables
try:
engine = create_engine_from_conf(seafile_config, db='seafile')
Expand Down
4 changes: 2 additions & 2 deletions dtable_events/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dtable_events.app.log import LogConfigurator
from dtable_events.app.config import get_config, is_syslog_enabled, get_task_mode
from dtable_events.app.event_redis import redis_cache
from dtable_events.db import create_db_tables, prepare_db_tables
from dtable_events.db import create_db_tables, prepare_seafile_tables


def main():
Expand All @@ -37,7 +37,7 @@ def main():

try:
create_db_tables(config)
prepare_db_tables(seafile_config)
prepare_seafile_tables(seafile_config)
except Exception as e:
logging.error('Failed create or prepare tables, error: %s' % e)
raise RuntimeError('Failed create or prepare tables, error: %s' % e)
Expand Down
4 changes: 2 additions & 2 deletions dtable_events/virus_scanner/run_virus_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import argparse

from dtable_events.db import prepare_db_tables
from dtable_events.db import prepare_seafile_tables
from dtable_events.virus_scanner.scan_settings import Settings
from dtable_events.virus_scanner.virus_scan import VirusScan

Expand Down Expand Up @@ -43,7 +43,7 @@

setting = Settings(config, seafile_config)
if setting.is_enabled():
prepare_db_tables(seafile_config)
prepare_seafile_tables(seafile_config)
VirusScan(setting).start()
else:
logger.info('Virus scan is disabled.')
6 changes: 3 additions & 3 deletions dtable_events/virus_scanner/virus_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def scan_file_virus(self, repo_id, file_id, file_path):
for blk_id in seafile.blocks:
os.write(tfd, block_mgr.load_block(repo_id, 1, blk_id))

log_dir = os.path.join(os.environ.get('SEAFEVENTS_LOG_DIR', ''))
log_dir = os.path.join(os.environ.get('LOG_DIR', ''))
logfile = os.path.join(log_dir, 'virus_scan.log')
with open(logfile, 'a') as fp:
ret_code = subprocess.call([self.settings.scan_cmd, tpath], stdout=fp, stderr=fp)
Expand All @@ -132,8 +132,8 @@ def send_email(self, vrecords):
cmd = [
get_python_executable(),
os.path.join(dtable_web_dir, 'manage.py'),
'notify_admins_on_virus',
] + args
'notify_admins_on_virus'
]
subprocess.Popen(cmd, cwd=dtable_web_dir)

def parse_scan_result(self, ret_code):
Expand Down

0 comments on commit 567d092

Please sign in to comment.