Un gestionnaire en Curses de machines virtuelles pour KVM/Libvirt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

61 lines
2.1 KiB

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, shutil
import curses
from appdirs import *
import data_manager
from ui import UI, display_manager
from logger import Logger
def check_install(dirs):
script_path = os.path.dirname(os.path.realpath(__file__))
original_conf_path = os.path.join(script_path, 'config')
config_dir = dirs.user_config_dir
if not os.path.exists(config_dir):
try:
print '\033[92mCreating config directory:\033[0m %s' % config_dir
os.makedirs(config_dir)
except Exception as e:
print '\033[91mError while trying to create %s:\n%s\033[0m' % (config_dir, str(e))
exit(1)
print '\033[92mCopying configuration file from package to config dir %s/ :\033[0m' % config_dir
for conf_file in os.listdir(original_conf_path):
original_conf_file = os.path.join(original_conf_path, conf_file)
dest_file = os.path.join(config_dir, conf_file)
if os.path.isfile(original_conf_file):
print '* %s -> %s' % (original_conf_file, dest_file)
shutil.copy(original_conf_file, dest_file)
if __name__ == "__main__":
#~ logger = Logger('/tmp/', True, 'info')
#~ dataManager = data_manager.DataManager(logger)
#~ displayManager = display_manager.DisplayManager(dataManager, logger)
#~ ui = UI(15, 150, displayManager, logger)
try:
dirs = AppDirs("pyCursesVirtMgr", "Red AtomiK")
check_install(dirs)
logger = Logger(dirs.user_log_dir, True, 'info')
dataManager = data_manager.DataManager(logger)
displayManager = display_manager.DisplayManager(dataManager, logger)
ui = UI(15, 150, displayManager, logger)
except Exception as e:
# Restore terminal state
try:
curses.echo()
curses.nocbreak()
curses.curs_set(1)
curses.endwin()
except:
pass
print e
quit(1)
# Restore terminal state
try:
curses.echo()
curses.nocbreak()
curses.curs_set(1)
curses.endwin()
except:
pass
quit(0)