Exemple #1
0
import os, sys, traceback, subprocess

from joecceasy import Easy

timeout = 5
print(f'About to get input (with timeout)...')
print(f'Note that default input will be received after {timeout} seconds.')
got = Easy.Input(f'Input - hurry, before {timeout} second timeout!:',
                 timeout=timeout,
                 default=None)
print(f'received input was: {got}\n{repr(got)}    {type(got)}')
Exemple #2
0
from joecceasy import Easy

intro = r"""
Easy.Input Example
======================

This script has inputs with timeouts!

Easy.Input is clumsy, only use it for simplest cases.

Behaviour of further calls to Easy.Input, after one of them times out, is awful in terms of user experience. Perhaps use Ascui instead? Or something like whip tail etc.


"""

print(intro, end="")

greeting = Easy.Input("\n\n" + "Please enter a greeting (5 second timeout):",
                      5, "Hello")
print(f'greeting is: {repr(greeting)}')

message = Easy.Input("\n\n" + "Please enter a message (6 sec timeout):",
                     timeout=6,
                     default="It's a wonderful world.  :)  ")
print(f'message is: {repr(message)}')
Exemple #3
0
#!/usr/bin/python3
from joecceasy import Easy

pkg = "isodate"  ## note that this testing script
## assumes pkg name is same as mod name,
## like "isodate" example.
## The test will fail otherwise,
## but Easy.PipInstall feature can be used without
## matching names as long as care is taken to use the
## correct different pkg and mod names

try:
    pkgMod = Easy.Mods[pkg]
except:
    print(f""" {pkg} package not found, attempting pip install...""")
    Easy.PipInstall(pkg)
    print(f""" {pkg} package installed """)
    pkgMod = Easy.Mods[pkg]

print(f"dir function used on pkg {pkg} shows:")
print(dir(pkgMod))

Easy.Input('press enter to exit or wait 5 sec for timeout', 5, warn=0)