Skip to content

Commit b3d52d0

Browse files
committed
Adding config editor for pip package
1 parent 4116d07 commit b3d52d0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

datasploit_config.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
3+
import os, subprocess, tempfile
4+
5+
def edit():
6+
config_path = os.path.dirname(__file__)
7+
config_file = "%s/config.py" % config_path
8+
fh = open(config_file)
9+
config = fh.read()
10+
fh.close()
11+
f, fname = tempfile.mkstemp()
12+
fh = open(fname, "w")
13+
fh.write(config)
14+
fh.close()
15+
16+
cmd = os.environ.get('EDITOR', 'vi') + ' ' + fname
17+
subprocess.call(cmd, shell = True)
18+
19+
with open(fname, "r") as f:
20+
config = f.read().strip()
21+
fh = open(config_file, "w")
22+
fh.write(config)
23+
fh.close()
24+
25+
os.unlink(fname)
26+
27+
if __name__ == "__main__":
28+
edit()

0 commit comments

Comments
 (0)