예제 #1
0
def main() -> int:
    dumpconf = 'dumpconf'
    initdb = 'initdb'
    parser = argparse.ArgumentParser()
    parser.add_argument('action',
                        choices=[dumpconf, initdb, 'refresh'],
                        help='Action to perform')
    parser.add_argument('-c',
                        '--conf',
                        default=None,
                        help='Configuration file')
    parser.add_argument('-f',
                        '--force',
                        default=False,
                        action='store_true',
                        help='Force action (default: False)')
    args = parser.parse_args()
    if not config.init(args.conf):
        log.error(f'Cannot parse configuration file: {args.conf}')
        sys.exit(1)
    if dumpconf == args.action:
        config.write(sys.stdout)
    elif initdb == args.action:
        RefreshLog.init(create_all=True)
    else:
        ClamavRefresh(args).refresh_all()
    return 0
예제 #2
0
 def setUp(self) -> None:
     super().setUp()
     RefreshLog.init(create_all=True)
     self.s = RefreshLog._session()
     self.s.query(RefreshLog).delete()
     self.s.add(RefreshLog(ID1))
     self.s.commit()
예제 #3
0
 def setUp(self) -> None:
     super().setUp()
     self.ci = _ClamavTestItem(url=URL1, section=self.UNITTEST, option='option', path='path')
     RefreshLog.init()
     self.s = RefreshLog._session()
     self.s.query(RefreshLog).delete()
     self.s.add(RefreshLog(self.ci, DIGEST_DUMMY))
     self.s.commit()
예제 #4
0
 def setUp(self) -> None:
     super().setUp()
     RefreshLog.init()
     self.s = RefreshLog._session()
     self.s.query(RefreshLog).delete()
     cia = _ClamavTestItem('spam', 'option', 'a', path='a')
     cib = _ClamavTestItem('spamalot', 'option', 'b', path='b')
     self.s.add(RefreshLog(cia, 'dummy'))
     self.s.add(RefreshLog(cib, 'dummy'))
     self.s.commit()
     self.s.commit()
예제 #5
0
 def setUp(self) -> None:
     super().setUp()
     RefreshLog.init()
     self.s = RefreshLog._session()
     self.s.query(RefreshLog).delete()
     self.s.commit()