lib: Move the "expired" for gencache_parse calculation into gencache.c
[Samba.git] / python / samba / mdb_util.py
blob4dbff48b05a2da2dee8b6671509966cecd5a416c
1 # Unix SMB/CIFS implementation.
2 # mdb util helpers
4 # Copyright (C) Andrew Bartlett <abartlet@samba.org> 2018
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import samba
20 import subprocess
21 import os
24 def mdb_copy(file1, file2):
25 """Copy mdb file using mdb_copy utility and rename it
26 """
27 # Find the location of the mdb_copy tool
28 dirs = os.getenv('PATH').split(os.pathsep)
29 for d in dirs:
30 toolpath = os.path.join(d, "mdb_copy")
31 if os.path.exists(toolpath):
32 break
34 mdb_copy_cmd = [toolpath, "-n", file1, "%s.copy.mdb" % file1]
35 status = subprocess.check_call(mdb_copy_cmd, close_fds=True, shell=False)
37 os.rename("%s.copy.mdb" % file1, file2)