db_run.py 552 B

1234567891011121314151617181920
  1. from concurrent.futures import ThreadPoolExecutor
  2. from pathlib import Path
  3. import subprocess
  4. import sys
  5. def task(name):
  6. print(Path(name).name)
  7. return subprocess.Popen(f'C:\\Windows\\System32\\cmd.exe /C "{name}"', stdout=subprocess.DEVNULL).wait()
  8. def main(base_dir):
  9. files = [str(f) for f in Path(base_dir).glob('*.bat') if not f.name.startswith('_')]
  10. with ThreadPoolExecutor(max_workers=5) as executor:
  11. executor.map(task, files)
  12. if __name__ == '__main__':
  13. main(f"C:\\GlobalCube\\System\\{sys.argv[1]}\\SQL\\batch")