def pick_aliasfile(saliasfile="", bexit_on_refusal=True): """ force user to select a good alias file, or create a blank one """ sfile = saliasfile dlg = Dialogs() while (not os.path.isfile(sfile)): dlg.msgbox( "No alias file found, click ok to select one to use.", dlg.info) sfile = dlg.dialog("Select an alias file to use:") # good aliasfile? if os.path.isfile(sfile): settings.setsave("aliasfile", sfile) else: # print("pick_aliasfile: Alias file not found!: " + sfile) response = dlg.msgbox_yesno('\n'.join(( 'Alias file not found,' ' Would you like to create a blank alias file?'))) if response == gtk.RESPONSE_NO: # print("No alias file, quitting...") if bexit_on_refusal: dlg.msgbox( '{} cannot run with an alias file, goodbye,'.format( settings.name), dlg.info) sys.exit(1) else: return "" else: integrator = aliasmgr_integrator.am_integrator() sblankfile = os.path.join(integrator.home, "bash.alias.sh") create_blank_file(sblankfile, True) # return good alias filename return sfile
def pick_aliasfile(saliasfile="", bexit_on_refusal=True): """ force user to select a good alias file, or create a blank one """ sfile = saliasfile dlg = Dialogs() while (not os.path.isfile(sfile)): dlg.msgbox( "No alias file found, click ok to select one to use.", dlg.info) sfile = dlg.dialog("Select an alias file to use:") # good aliasfile? if os.path.isfile(sfile): settings.setsave("aliasfile", sfile) else: # print("pick_aliasfile: Alias file not found!: " + sfile) response = dlg.msgbox_yesno( "Alias file not found,\n Would you like to create a blank alias file?", ) if response == gtk.RESPONSE_NO: # print("No alias file, quitting...") if bexit_on_refusal: dlg.msgbox( settings.name + " cannot run with an alias file, goodbye,", dlg.info) sys.exit(1) else: return "" else: integrator = aliasmgr_integrator.am_integrator() sblankfile = os.path.join(integrator.home, "bash.alias.sh") create_blank_file(sblankfile, True) # return good alias filename return sfile
@author: Christopher Welborn ''' import re import gtk import os import sys import aliasmgr_integrator import aliasmgr_settings # For changing file mode when scripts are generated. from stat import S_IREAD, S_IWRITE, S_IEXEC # Shorthand for read, write, and exec. S_RWX = S_IREAD | S_IWRITE | S_IEXEC settings = aliasmgr_settings.am_settings() integrator = aliasmgr_integrator.am_integrator() # Command/Alias Object ------------------------------------ class Command(): def __init__(self, name=None, cmd=None, comment=None, exported=None): # set defaults. self.name = name if name else '' self.cmd = cmd if cmd else [] self.comment = comment if comment else '' self.exported = exported if exported else 'New' self.shebang = '#!/bin/bash' def __repr__(self): """ return string representation of this command. """