-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_ramdisk_example.py
More file actions
executable file
·83 lines (67 loc) · 2.22 KB
/
Copy pathsetup_ramdisk_example.py
File metadata and controls
executable file
·83 lines (67 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env -S python -u
"""
"""
#--- Native python libraries
import sys
from optparse import OptionParser
from PySide6.QtWidgets import QApplication
sys.path.append("../")
#--- non-native python libraries in this source tree
from ramdisk.lib.loggers import CyLogger
from ramdisk.lib.loggers import LogPriority as lp
from ramdisk.ui.main import _CreateRamdisk
from ramdisk.RamDisk import RamDisk
parser = OptionParser(usage="\n\n%prog [options]\n\n", version="2.8.6")
size = str(500) # in Megabytes
parser.add_option("-s", "--size", dest="size",
default=str(size),
help="Size of ramdisk you want to create in 1 Megabyte blocks")
parser.add_option("-m", "--mount-point", dest="mntpnt",
default="",
help="Name of the mountpoint you want to mount to")
parser.add_option("-g", "--gui", action="store_true", dest="gui",
default=0, help="Print debug messages")
parser.add_option("-d", "--debug", action="store_true", dest="debug",
default=0, help="Print debug messages")
parser.add_option("-v", "--verbose", action="store_true",
dest="verbose", default=0,
help="Print status messages")
(opts, args) = parser.parse_args()
if opts.verbose != 0:
level = lp.INFO
elif opts.debug != 0:
level = level=lp.DEBUG
else:
level=lp.WARNING
logger = CyLogger(level)
logger.initializeLogs()
if opts.size:
size = str(opts.size) # in Megabytes
if opts.gui:
app = QApplication(sys.argv)
"""
# Set up event logger
init_event_logger(
os.path.join(get_current_directory(), "event.log"),
"%(asctime)s - %(levelname)s - %(message)s",
stdout=True,
debug=True if "--debug" in sys.argv else False,
)
"""
print("started app...")
window = _CreateRamdisk()
print("initiated window")
window.show()
print("showing window...")
window.raise_()
print("raising_ window")
sys.exit(app.exec())
else:
mntpnt = opts.mntpnt
ramdisk = RamDisk(str(size), str(mntpnt), logger)
ramdisk.getNlogData()
ramdisk.getNprintData()
#if not ramdisk.success:
# raise Exception("Ramdisk setup failed..")
#print(ramdisk.getDevice())
#time.sleep(9000)