Example #1
0
def passDialog(kid, retry = False, image = image_path):
  """Displays password prompt using Pashua. Returns password as string and save checkbox
  state as 0 or 1."""

  message = 'Ticket for %s expired. Enter your password to renew:' % kid
  if retry: message = 'Your password was incorrect. Please try again:'

  # Dialog config
  conf = '''
  # Window
  *.title = Kerberos Ticket Renewal
  *.floating = 1

  # Image/logo
  img.type = image
  img.path = %s
  img.maxwidth = 64
  img.border = 0
  img.x = 0
  img.y = 100

  # Message
  msg.type = text
  msg.text = %s
  msg.x = 80
  msg.y = 110

  # Password field
  psw.type = password
  psw.mandatory = 1
  psw.width = 280
  psw.x = 82
  psw.y = 70

  # Save checkbox
  save.type = checkbox
  save.label = Remember this password in my keychain
  save.x = 80
  save.y = 45

  # Default button
  db.type = defaultbutton
  db.label = OK

  # Cancel button
  cb.type = cancelbutton
  cb.label = Cancel
  ''' % (image,message)

  # Open dialog and get input
  dialog = Pashua.run(conf)

  # Check for Cancel before return
  if dialog['cb'] == '1':
    logPrint('User canceled.')
    sys.exit(0)

  return dialog['psw'], dialog['save']
Example #2
0
# Set the images' paths relative to Pashua.app's path
# app_bundle = os.path.dirname(os.path.dirname(Pashua.locate_pashua()))
# icon = app_bundle + '/Resources/[email protected]'
#
# if os.path.exists(icon):
#     # Display Pashua's icon
#     conf += """img.type = image
#                img.x = 435
#                img.y = 248
#                img.maxwidth = 128
#                img.tooltip = This is an element of type 'image'
#                img.path = %s""" % icon
#

result = Pashua.run(conf)

print("Pashua returned the following dictionary keys and values:")

for key in result.keys():
    print("%s = %s" % (key, result[key]))

if result['cb']=='1':
    sys.exit()

image_path = result['ob']
image_file = os.path.basename(image_path)
image_comps = os.path.splitext(image_file)
dirname = os.path.split(os.path.dirname(image_path))[1]

caption=result['tf']
Example #3
0
# Set the images' paths relative to Pashua.app's path
# app_bundle = os.path.dirname(os.path.dirname(Pashua.locate_pashua()))
# icon = app_bundle + '/Resources/[email protected]'
#
# if os.path.exists(icon):
#     # Display Pashua's icon
#     conf += """img.type = image
#                img.x = 435
#                img.y = 248
#                img.maxwidth = 128
#                img.tooltip = This is an element of type 'image'
#                img.path = %s""" % icon
#

result = Pashua.run(conf)

# print("Pashua returned the following dictionary keys and values:")

# for key in result.keys():
#     print("%s = %s" % (key, result[key]))

if result['cb'] == '1':
    sys.exit()

source_image_path = result['source']

dest_image_path = result['dest']

if result['recursive'] == '1':
    if os.path.isdir(dest_image_path):
Example #4
0
def login_dialog(image):  # pragma: no cover
    """Displays login and password prompt using Pashua. Returns login as string."""

    message = 'Computer is not bound to AD. Enter your Kerberos credentials:'

    # Dialog config
    conf = '''
    # Window
    *.title = Kerberos Ticket Creation
    *.floating = 1

    # Image/logo
    img.type = image
    img.path = %s
    img.maxwidth = 128
    img.border = 0

    # Message
    msg.type = text
    msg.text = %s

    # Login field
    login.type = textfield
    login.label = Login:
    login.default = login
    login.width = 280
    login.mandatory = 1
    ''' % (image, message)

    try:
        realms = g_prefs.get_realms()
        conf += '''
            # Add a popup menu
            realm.type = popup
            realm.width = 285
            realm.label = Domain:
            '''
        for realm in realms:
            conf = conf + "realm.option = " + realm + "\n"
    except (KeyError, IOError):
        conf += '''
            realm.type = textfield
            realm.width = 280
            realm.label = Domain:
            '''

    conf += '''
    # Default button
    db.type = defaultbutton
    db.label = OK
    db.x = 0
    db.y = 0

    # Cancel button
    cb.type = cancelbutton
    cb.label = Cancel
    '''

    # Open dialog and get input
    dialog = Pashua.run(conf)

    # Check for Cancel before return
    if dialog['cb'] == '1':
        log_print('User canceled.')
        sys.exit(0)

    return dialog['login'] + '@' + dialog['realm'].upper()
Example #5
0
def pass_dialog(kid, image, retry=False):  # pragma: no cover
    """Displays password prompt using Pashua.
    Returns password as string and save checkbox state as 0 or 1.
    """

    message = 'Ticket for %s expired. Enter your password to renew:' % kid
    if retry:
        message = 'Your password was incorrect. Please try again:'

    # Dialog config
    conf = '''
    # Window
    *.title = Kerberos Ticket Renewal
    *.floating = 1

    # Image/logo
    img.type = image
    img.path = %s
    img.maxwidth = 64
    img.border = 0
    img.x = 0
    img.y = 100

    # Message
    msg.type = text
    msg.text = %s
    msg.x = 80
    msg.y = 110

    # Password field
    psw.type = password
    psw.mandatory = 1
    psw.width = 280
    psw.x = 82
    psw.y = 70

    # Save checkbox
    save.type = checkbox
    save.label = Remember this password in my keychain
    save.x = 80
    save.y = 45
    save.default = 1

    # Default button
    db.type = defaultbutton
    db.label = OK

    # Cancel button
    cb.type = cancelbutton
    cb.label = Cancel
    ''' % (image, message)

    # Open dialog and get input
    dialog = Pashua.run(conf)

    # Check for Cancel before return
    if dialog['cb'] == '1':
        log_print('User canceled.')
        sys.exit(0)

    return dialog['psw'], dialog['save']
# Set the images' paths relative to Pashua.app's path
# app_bundle = os.path.dirname(os.path.dirname(Pashua.locate_pashua()))
# icon = app_bundle + '/Resources/[email protected]'
#
# if os.path.exists(icon):
#     # Display Pashua's icon
#     conf += """img.type = image
#                img.x = 435
#                img.y = 248
#                img.maxwidth = 128
#                img.tooltip = This is an element of type 'image'
#                img.path = %s""" % icon
#

result = Pashua.run(conf.encode('utf8'))

# print("Pashua returned the following dictionary keys and values:")

# for key in result.keys():
#     print("%s = %s" % (key, result[key]))

if result['cb'] == '1':
    sys.exit()

caption = result['tf']
dest_image_path = result['dest']

if result['recursive'] == '1':

    if os.path.isdir(dest_image_path):
Example #7
0
def loginDialog(image = image_path):
  """Displays login and password prompt using Pashua. Returns login and password as string and save checkbox
  state as 0 or 1."""

  message = 'Computer is not bound to AD. Enter your Kerberos credentials:'

  # Dialog config
  conf = '''
  # Window
  *.title = Kerberos Ticket Creation
  *.floating = 1

  # Image/logo
  img.type = image
  img.path = %s
  img.maxwidth = 64
  img.border = 0
  img.x = 0
  img.y = 110

  # Message
  msg.type = text
  msg.text = %s
  msg.x = 80
  msg.y = 130
  
  # Login Message
  loginmsg.type = text
  loginmsg.text = Login: 
  loginmsg.x = 80
  loginmsg.y = 100

  # Login field
  login.type = textfield
  login.default = [email protected]
  login.mandatory = 1
  login.width = 280
  login.x = 82
  login.y = 70

  # Do not ask again checkbox
  dna.type = button
  dna.label = Do not use KerbMinder

  # Default button
  db.type = defaultbutton
  db.label = OK

  # Cancel button
  cb.type = cancelbutton
  cb.label = Cancel
  ''' % (image,message)

  # Open dialog and get input
  dialog = Pashua.run(conf)

  # Check for Cancel before return
  if dialog['cb'] == '1':
    logPrint('User canceled.')
    sys.exit(0)

  if dialog['dna'] == '1':
    setDoNotAsk()

  return dialog['login']
Example #8
0
def login_dialog(image): # pragma: no cover
    """Displays login and password prompt using Pashua. Returns login as string."""

    message = 'Computer is not bound to AD. Enter your Kerberos credentials:'

    # Dialog config
    conf = '''
    # Window
    *.title = Kerberos Ticket Creation
    *.floating = 1

    # Image/logo
    img.type = image
    img.path = %s
    img.maxwidth = 128
    img.border = 0

    # Message
    msg.type = text
    msg.text = %s

    # Login field
    login.type = textfield
    login.label = Login:
    login.default = login
    login.width = 280
    login.mandatory = 1
    ''' % (image, message)

    try:
        realms = g_prefs.get_realms()
        conf += '''
            # Add a popup menu
            realm.type = popup
            realm.width = 285
            realm.label = Domain:
            '''
        for realm in realms:
            conf = conf + "realm.option = " + realm + "\n"
    except (KeyError, IOError):
        conf += '''
            realm.type = textfield
            realm.width = 280
            realm.label = Domain:
            '''

    conf += '''
    # Default button
    db.type = defaultbutton
    db.label = OK
    db.x = 0
    db.y = 0

    # Cancel button
    cb.type = cancelbutton
    cb.label = Cancel
    '''

    # Open dialog and get input
    dialog = Pashua.run(conf)

    # Check for Cancel before return
    if dialog['cb'] == '1':
        log_print('User canceled.')
        sys.exit(0)

    return dialog['login'] + '@' + dialog['realm'].upper()
Example #9
0
db.label = Clipboard

# Cancel button
cb.type = cancelbutton
'''

# Capture a portion of the screen and save it to a temporary file.
status = subprocess.call(["screencapture", "-io", "-t", type, tfname])

# Exit if the user canceled the screencapture.
if not status == 0:
    os.remove(tfname)
    sys.exit()

# Open the dialog box and get the input.
dialog = Pashua.run(conf)
if dialog['cb'] == '1':
    os.remove(tfname)
    sys.exit()

# Add a desktop background border if asked for.
snap = Image.open(tfname)
if dialog['bd'] == '1':
    # Make a solid-colored background bigger than the screenshot.
    snapsize = tuple([x + 2 * border for x in snap.size])
    bg = Image.new('RGB', snapsize, bgcolor)
    bg.paste(snap, (border, border))
    bg.save(tfname)

# Optimize the file.
subprocess.call([optipng, '-quiet', tfname])
chk1.default = 1

# Add another one
chk2.type = checkbox
chk2.label = But this one is disabled
chk2.disabled = 1

# Add a cancel button with default label
cb.type=cancelbutton

"""

# Set the images' paths relative to this file's path /
# skip images if they can not be found in this file's path
icon = os.path.dirname(__file__) + '/.icon.png'
bgimg = os.path.dirname(__file__) + '/.demo.png'
if os.path.exists(icon):
    # Display Pashua's icon
    conf += "img.type = image\nimg.x = 530\nimg.y = 255\nimg.path = %s\n" % icon
if os.path.exists(bgimg):
    # Display Pashua's icon
    conf += "bg.type = image\nbg.x = 30\nbg.y = 2\nbg.path = %s\n" % bgimg


result = Pashua.run(conf, 'utf8')

print("Pashua returned the following dictionary keys and values:")

for key in result.keys():
    print("%s = %s" % (key, result[key]))