コード例 #1
0
def draw(sim_steps, cols, rows, a_grid, b_grid, redistribution_grid):
    screen = terminal.get_terminal(conEmu=False)
    if sim_steps < 2:
        screen.clear()
    screen.gotoXY(0, 0)
    a_fuel = sum(a_grid)
    b_fuel = sum(b_grid)
    print "STEP:%3d\tFUEL: A:%8d\tB:%8d\tA+B:%8d" % (sim_steps, a_fuel, b_fuel, a_fuel + b_fuel)
    print '\nRED:\tPlayer A\nGREEN:\tPlayer B\nBLACK:\tCell Weight'

    y_offset = 8
    norm = 99. / max([1] + a_grid + b_grid)
    for row in range(rows):
        for col in range(cols):
            idx = row * cols + col
            owner = '   '
            r = hex(redistribution_grid[idx] / 16)[-1]
            #r = '%3d' % redistribution_grid[idx]
            if a_grid[idx]:
                owner = '%2d' % (a_grid[idx] * norm)
                c = red
            elif b_grid[idx]:
                owner = '%2d' % (b_grid[idx] * norm)
                c = green
            else:
                c = black
                owner = '%2d' % (redistribution_grid[idx] * 100 / 256)
            screen.gotoXY(1+ col*3, y_offset + row)
            screen.xterm256_set_bk_color(c)
            print owner,
        print
    screen.xterm256_set_bk_color(black)
    time.sleep(.04)
コード例 #2
0
ファイル: __main__.py プロジェクト: JTSDK/jtsdk64-tools-dep
def header(text, value):
    """Print header with text and underline value"""
    screen = terminal.get_terminal(conEmu=False)
    print("-" * value)
    screen.set_color(3, 0)
    print(f"{text}")
    screen.reset_colors()
    print("-" * value)
コード例 #3
0
def supported_versions():
    """Print list of supported QT Frameworks from qt_version_dict"""
    clear()
    screen = terminal.get_terminal(conEmu=False)
    print("---------------------------------------------")
    screen.set_color(3, 0)
    print(f"Supported QT Frameworks")
    screen.reset_colors()
    print("---------------------------------------------\n")
    for k, v in qt_version_dict.items():
        print(f" Version {k} using {v}")
コード例 #4
0
ファイル: beast.py プロジェクト: efigence/ralph_beast
def cprint(string, color='WHITE', verbose=False):
    if sys.stdout.isatty():
        term = terminal.get_terminal()
        term.set_color(terminal.colors[color])
        if verbose:
            if SHOW_VERBOSE:
                sys.stdout.write(string)
        else:
            sys.stdout.write(string)
        term.reset()
    else:
        if not verbose:
            sys.stdout.write(string)
コード例 #5
0
ファイル: pyfos_util.py プロジェクト: sun-deepv/Pyfostest
def test_title_set(title, description):
    global current_test
    global screen
    if screen is None:
        screen = terminal.get_terminal(conEmu=False)
    if current_test is None:
        print('\nStarting test case:', title, "::", description, "::", end="")
        current_test = test(title, description)
    else:
        print_current_test()
        executed_tests.append(current_test)
        print('Starting test case:', title, "::", description, "::", end="")
        current_test = test(title, description)
コード例 #6
0
ファイル: beast.py プロジェクト: jjagodzinski/ralph_beast
def cprint(string, color='WHITE', verbose=False):
    if sys.stdout.isatty():
        term = terminal.get_terminal()
        term.set_color(terminal.colors[color])
        if verbose:
            if SHOW_VERBOSE:
                sys.stdout.write(string)
        else:
            sys.stdout.write(string)
        term.reset()
    else:
        if not verbose:
            sys.stdout.write(string)
コード例 #7
0
ファイル: __main__.py プロジェクト: JTSDK/jtsdk64-tools-dep
def supported_versions():
    """Print list of supported QT Frameworks from qt_version_dict"""
    clear()
    screen = terminal.get_terminal(conEmu=False)
    screen.set_color(3, 0)
    print(f"\nSupported QT Frameworks\n")
    screen.reset_colors()
    print(f"{'Version':<12} {'GCC':<10} {'Available':<10} {'Installed'}")
    print("-" * 50)
    for k, v in qt_version_dict.items():
        path = os.path.join(qthome, k)
        if os.path.isdir(path):
            print(f"{k:<8} {v:<17} {'Yes':<10} {'Yes'}")
        else:
            print(f"{k:<8} {v:<17} {'Yes':<10} {'No'}")
コード例 #8
0
ファイル: messages.py プロジェクト: JTSDK/jtsdk64-tools-dep
def main_header_message():
    """JTSDK64 Main Menu Headder Message"""
    screen = terminal.get_terminal(conEmu=False)
    clear()
    print("--------------------------------------------------")
    screen.set_color(3, 0)
    print(f"JTSDK64 Tools {os.environ['VERSION']}")
    screen.reset_colors()
    print("--------------------------------------------------")
    print('{0:18}  {1}'.format("\nQT Version", os.environ["QTV"]))
    print('{0:17}  {1}'.format("Core Tools", os.environ["CORETOOLS"]))
    print('{0:17}  {1}'.format("Python", os.environ["PYTOOLS"]))
    print('{0:17}  {1}'.format("Postgres", os.environ["POSTGRES"]))
    print('{0:17}  {1}'.format("Unix Tools", os.environ["UNIXTOOLS"]))
    print("\nFor Command List, Type: jthelp\n")
コード例 #9
0
ファイル: loading.py プロジェクト: spgill/python-draftlog
    def __init__(self, frames=None):
        # Frames takes each frame seperated by a space with the very last frame
        # being the "done" frame.

        # Initialize self into a threading object and start running it.
        super(Loading, self).__init__()
        self.text_queue = queue.Queue()
        self.setDaemon(True)

        # Internal variables
        if frames == None:
            self.change_frames("snake")
        else:
            self.frames = frames.split(" ")
            self.time = 0.03
        self.t = get_terminal()
        self.text = ""
        self.frame = 0
        sys.stdout.write("\x1b[7")
コード例 #10
0
def jt64_main_help():
    """Prints Main Help Message"""
    clear()
    screen = terminal.get_terminal(conEmu=False)
    print("------------------------------------------------------------")
    screen.set_color(3, 0)
    print(f"JTSDK64 Tools {os.environ['VERSION']} Help Menu")
    screen.reset_colors()
    print("------------------------------------------------------------")
    print("")
    print("The following commands are available throughout the JTSDK64")
    print("Tools Environment.")
    print("\nScripts Commands\n")
    print('{0:15}  {1}'.format("  jt64help", "Print This Help Menu"))
    print('{0:15}  {1}'.format("  jt64env", "Lists All Environment Variables"))
    print('{0:15}  {1}'.format("  jt64gentc", "Generate Tool Chain Files"))
    print('{0:15}  {1}'.format("  jt64version", "Checks Tool-Chain Versions"))
    print("\nShortcut Commands\n")
    print('{0:15}  {1}'.format("  home", "Return back to home directory"))
    print('{0:15}  {1}'.format("  msys2", "Launch MSYS2 Console"))
コード例 #11
0
def main():
    clear()
    """JTSDK Main Menu Headder Message"""
    list = ', '.join(list_tcfiles())
    qtver = os.environ["QTV"]
    clear()
    screen = terminal.get_terminal(conEmu=False)
    print("--------------------------------------------------")
    screen.set_color(3, 0)
    print(f"JTSDK64 Tools {os.environ['VERSION']} Version Check")
    screen.reset_colors()
    print("--------------------------------------------------\n")
    print(f" QT {os.environ['QTV']} Tool Chain\n")
    print(f"   JT64 Version  : {__version__}")
    print(f"   Qt Version    : {qtver}")
    print(f"   Qt Version    : {qtver}")
    print(f"   Qmake         : {get_qmake_version()}")
    print(f"   GCC           : {get_gcc_version()}")
    print(f"   Mingw32-Make  : {get_mingw32_make_version()}")
    print(f"   TC Files      : {list}")
    print("\n General Purpose Tools\n")
    print(f"   Cmake         : {get_cmake_version()}")
    print(f"   Asciidoctor   : {get_asciidoctor_version()}")
    print(f"   Bash          : {get_bash_version()}")
    print(f"   FFTW          : {get_fftw_version()}")
    print(f"   Git           : {get_git_version()}")
    print(f"   Libusb        : {get_libusb_version()}")
    print(f"   NSIS          : {get_nsis_version()}")
    print(f"   Pkg-Config    : {get_pkgconfig_version()}")
    print(f"   PostgreSQL    : {get_psql_version()}")
    print(f"   SQLite3       : {get_sqlite_version()}")
    print(f"   Subversion    : {get_subversion_version()}")
    print('''
 JTSDK64 Tools Version v3.1.0 Alpha
 Copyright (C) 2013-2019, GPLv3, Greg Beam, KI7MT
 This is free software; There is NO warranty; not even
 for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    ''')
コード例 #12
0
def main():
    """Prints JTSDK64 Tools Environment Variables """
    clear()

    # setup the parser
    parser = argparse.ArgumentParser(add_help=True, description=__summary__)
    parser.add_argument('-v', '--version',
                        action='version',
                        version='%(prog)s ' + __version__,
                        help='display module version')

    # process the arguments
    args = parser.parse_args()

    screen = terminal.get_terminal(conEmu=False)
    print("------------------------------------------------------------")
    screen.set_color(3, 0)
    print(f"JTSDK64 Tools {os.environ['VERSION']} Environment Variables")
    screen.reset_colors()
    print("------------------------------------------------------------")
    print("\nJTSDK Variables\n")
    print(f"  JTSDK Version ....: {env_item('JTSDK64_VERSION')}")
    print(f"  JTSDK Home .......: {env_item('JTSDK_HOME')}")
    print(f"  JTSDK Config .....: {env_item('JTSDK_CONFIG')}")
    print(f"  JTSDK Data .......: {env_item('JTSDK_DATA')}")
    print(f"  JTSDK Tmp ........: {env_item('JTSDK_TMP')}")
    print(f"  JTSDK Scripts ....: {env_item('JTSDK_SCRIPTS')}")
    print("\nQT Variables\n")
    print(f"  QT Version  ......: {env_item('QTV')}")
    print(f"  QT Directory .....: {env_item('QTD')}")
    print(f"  QT Plugins .......: {env_item('QTP')}")
    print(f"  GCC Directory ....: {env_item('GCCD')}")
    print("\nConfiguration Options\n")
    print(f"  Python Tools .....: {env_item('PYTOOLS')}")
    print(f"  PostgreSQL .......: {env_item('POSTGRES')}")
    print(f"  Unix Tools .......: {env_item('UNIXTOOLS')}")
コード例 #13
0
    print("Export symbol summaries of [" + sys.argv[2] + "] now ...")
    with open(sys.argv[4], "a") as f:
        f.write("<item><name>" + sys.argv[2] + "</name><symbol_cnt>" +
                str(len(provided)) + "</symbol_cnt><undefined_cnt>" +
                str(len(used)) + "</undefined_cnt><should_be_static>" +
                str(should_be_static_cnt) + "</should_be_static><used_by>" +
                str(len(callers)) + "</used_by><depends_on>" +
                str(len(depends)) + "</depends_on><mutual_cnt>" +
                str(len(warnings)) + "</mutual_cnt><mutuals>" +
                ",".join(warnings) + "</mutuals></item>\n")
    # Close connection to database
    c.close()
    conn.close()
    sys.exit(0)

screen = terminal.get_terminal()

print("============================Dependence report for [" + sys.argv[2] +
      "]")
sys.stdout.write("Public functions count: ")
focus_text(str(len(provided)), screen)
sys.stdout.write("; Used by modules count: ")
focus_text(str(len(callers)), screen)
if should_be_static_cnt > 0:
    sys.stdout.write("; Not used public functions count:")
    err_text(str(should_be_static_cnt), screen)
sys.stdout.write("\nCalled functions count: ")
focus_text(str(len(used)), screen)
sys.stdout.write("; Depends on moduls count: ")
focus_text(str(len(depends)), screen)
if len(warnings) > 0:
コード例 #14
0
import socket,sys,os
import kickstarter
import kickstarter_server_port as KSP
import Queue
from threading import active_count
from colorconsole import terminal
'''
pip install colorconsole
'''

REPOSITORY_NAME = 'repo_project'
CONTINUE_ = False # if True, only collect in-progress projects

screen = terminal.get_terminal() #get the currrent screen
screen.clear()
sys.stdout.flush()
def create_repository():
    if not os.path.exists(REPOSITORY_NAME):
        os.mkdir(REPOSITORY_NAME)
def display_hello():
    
    screen.gotoXY(0,1)
    screen.cprint(15,0,"= = = = = = = = = = = = = = = = = = = = = = = = = ")
    sys.stdout.flush()
    screen.gotoXY(0,2)
    screen.cprint(10,0,"         KICKSTARTER PROJECT PAGE COLLECTOR")
    sys.stdout.flush()
    screen.gotoXY(0,3)
    screen.cprint(15,0,"= = = = = = = = = = = = = = = = = = = = = = = = = ")
    sys.stdout.flush()
    screen.gotoXY(0,4)
コード例 #15
0
def initscreen():
    # pylint: disable=W0603
    global screen
    if screen is None:
        screen = terminal.get_terminal(conEmu=False)
コード例 #16
0
ファイル: solver.py プロジェクト: kapitanov/orbitals
 def print(self):
     """Вывод лога в консоль"""
     screen = terminal.get_terminal()
     for event in self._events:
         event.print(screen)
     screen.reset()
コード例 #17
0
ファイル: example1.py プロジェクト: MeetLuck/colorconsole
import math
from colorconsole import terminal

screen = terminal.get_terminal(conEmu=False)
screen.set_title("Example 1")
screen.set_color(terminal.colors["WHITE"], terminal.colors["BLUE"])
screen.clear()

PI = math.pi
step = (2.0*PI)/screen.columns()

for x in range(screen.columns()):
    screen.set_color(terminal.colors["YELLOW"], terminal.colors['RED'])
    screen.print_at(x, 11, "-")
    screen.set_color(2, 7)
    screen.print_at(x, 11+math.sin(x*step)*10, "S")
    screen.set_color(1, 2)
    screen.print_at(x, 11+math.cos(x*step)*10, "C")

screen.reset_colors()
# Waits for a single key touch before ending.
screen.getch()
コード例 #18
0
import socket, sys, os
import kickstarter
import kickstarter_server_port as KSP
import Queue
from threading import active_count
from colorconsole import terminal
'''
pip install colorconsole
'''

REPOSITORY_NAME = 'repo_project'
CONTINUE_ = False  # if True, only collect in-progress projects

screen = terminal.get_terminal()  #get the currrent screen
screen.clear()
sys.stdout.flush()


def create_repository():
    if not os.path.exists(REPOSITORY_NAME):
        os.mkdir(REPOSITORY_NAME)


def display_hello():

    screen.gotoXY(0, 1)
    screen.cprint(15, 0, "= = = = = = = = = = = = = = = = = = = = = = = = = ")
    sys.stdout.flush()
    screen.gotoXY(0, 2)
    screen.cprint(10, 0, "         KICKSTARTER PROJECT PAGE COLLECTOR")
    sys.stdout.flush()
コード例 #19
0
ファイル: __main__.py プロジェクト: JTSDK/jtsdk64-tools-dep
def main():
    """Generates Tool Chain files for each QT version in qt_version_list"""
    clear()

    # setup the parser
    parser = argparse.ArgumentParser(add_help=True, description=__summary__)

    parser.add_argument('-s',
                        '--supported',
                        action='store_true',
                        default=False,
                        dest='boolean_t',
                        help='list supported QT versions')

    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version='%(prog)s ' + __version__,
                        help='display module version')

    # process the arguments
    args = parser.parse_args()

    # if user requests supported versions
    if args.boolean_t:
        supported_versions()
    else:
        make_dir()
        screen = terminal.get_terminal(conEmu=False)
        print("------------------------------------------------------------")
        screen.set_color(3, 0)
        print(f"JTSDK64 Generate QT Tool Chain Files {os.environ['VERSION']}")
        screen.reset_colors()
        print("------------------------------------------------------------\n")

        # find installed verisons of Qt by checking for directories
        # TODO: move to jt64common, loop is used in jt64gentc and jt64setqt
        if os.path.isdir(qthome):
            for i in qt_version_list:
                path = os.path.join(qthome, i)
                if os.path.isdir(path):
                    available.append(str(i))
        else:
            print("Qt components do not appear to be installed yet.")
            sys.exit(0)

        # loop through each supported QT version and generate TC file
        # for testing, change the name of the Qt folder.
        for i in available:
            time_now = datetime.datetime.now()
            print(f"* Generating TC File for QT v{i}")
            file_name = "qt" + i.replace(".", "") + ".tc"
            file = os.path.join(tc_dir, file_name)

            # Qt Directory back slash
            qtdir = os.path.join(base_path, "tools", "Qt", i, "mingw73_64",
                                 "bin")
            qtdir = qtdir.replace('\\', '/')

            # Set GCCD: 5.12.2, 5.12.3, 5.12.4 and 5.13.0 use GCC 730_64
            gccd = os.path.join(base_path, "tools", "Qt", "Tools",
                                "mingw730_64", "bin")
            gccd = gccd.replace('\\', '/')

            # set the hHamlib directories
            hamlib_dir = os.path.join(hamlib_base_path, i)
            hamlib_dir = hamlib_dir.replace('\\', '/')

            # remove file while supressing not found error
            # TODO: move remove_file to jt64common
            with contextlib.suppress(FileNotFoundError):
                os.remove(file)

            # Open file
            with open(file, "w") as f:
                f.write(f"# " + 55 * "-" + "\n")
                f.write(f"# Tool Chain File for Qt {i}\n")
                f.write(f"# This file is auto-generated by : {script_name}\n")
                f.write(f"# Time Stamp: {time_now}\n")
                f.write(f"# " + 55 * "-" + "\n")
                f.write(f"\n# System Type and Base Paths\n")
                f.write(f"SET (CMAKE_SYSTEM_NAME Windows)\n")
                f.write(f"SET (QTDIR {qtdir})\n")
                f.write(f"SET (GCCD {gccd}\n")
                f.write(f"\n# Asciidoctor\n")
                f.write(f"SET (ADOCD {adoc_path})\n")
                f.write(f"\n# FFTW\n")
                f.write(f"SET (FFTWD {fftw_path})\n")
                f.write(f"\n# Hamlib\n")
                f.write(f"SET (HLIB {hamlib_dir})\n")
                f.write(f"\n# Subversion\n")
                f.write(f"SET (SVND {svn_path})\n")
                f.write(f"\n# CMake Consolidated variables\n")
                f.write(
                    "SET (CMAKE_PREFIX_PATH ${GCCD} ${QTDIR} ${HLIB} ${HLIB}/bin ${ADOCD} ${FFTWD} ${SVND})\n"
                )
                f.write(f"SET (CMAKE_FIND_ROOT_PATH_PROGRAM NEVER)\n")
                f.write(f"SET (CMAKE_FIND_ROOT_PATH_LIBRARY BOTH)\n")
                f.write(f"SET (CMAKE_FIND_ROOT_PATH_INCLUDE BOTH)\n")
                f.write(f"\n# END Cmake Tool Chain File")

            f.close()
コード例 #20
0
# ================================================================================
# Wayback Machine Endpoint Executor
# Developed by Tag Kim (Ph D.)
# This program is a data crawler designed to collect webpages in Wayback Machine.
# Visit http://web.archive.org to get more imformation.
#
# To run the program, you need to install drtag.web Python module.
# Send me an email: [email protected]
# All right reseved.
# ================================================================================
#Import parsers
from waybackmachine import *
import sys,os,glob
from colorconsole import terminal

screen = terminal.get_terminal()
screen.clear()
screen.gotoXY(0,0)

# --------------------------------------------------------------------------------
# --<CLASS>-----------------------------------------------------------------------
class MyMsg:
    menu = """1. Create Input File
2. Collect main pages yearly
3. Collect pages (1 level depth) from a data folder
4. Create a database schema
5. Map page data files onto a SQLite file
6. About the program
7. Exit"""
    menu_1 = """1. Check if your address exists
2. Create CSV input
コード例 #21
0
 def Execute(self):
     mylog.debug('Kitty will hang out for %s seconds' % self.kitty_time)
     screen = terminal.get_terminal()
     screen.clear()
     screen.set_title("=^..^=")
     tail = 'left'
     purr_time = False
     meow = False
     cute_time, cuteness = self.random_cute(self.kitty_time)
     cute_count = 1
     purr = None
     while self.kitty_time > 0:
         mylog.debug('Setting kitty screen parameters')
         mylog.debug('Kitty tail is %s' % tail)
         mylog.debug('Countdown to next cute time is %s seconds!' %
                     (cute_time - cute_count))
         ## Are we gonna do sumthin' cute? ##
         rlist, _, _ = select([sys.stdin], [], [], 1)
         if rlist:
             cute_check = sys.stdin.readline()
             if cute_check:
                 cuteness = self.cute_pick()
         if cute_count == cute_time:
             cute_time, cuteness = self.random_cute(self.kitty_time)
             cute_count = 0
         if cuteness == 'meow':
             meow = True
         if cuteness == 'purr':
             purr_time = True
         ## Gather kitty parameters and draw that kitty ##
         if purr_time:
             purr = 'left'
             self.draw_box(screen)
             kitty = self.kitty_art(tail, meow, purr)
             self.draw_kitty(screen, kitty)
             time.sleep(1)
             purr = 'right'
             self.draw_box(screen)
             kitty = self.kitty_art(tail, meow, purr)
             self.draw_kitty(screen, kitty)
         else:
             self.draw_box(screen)
             kitty = self.kitty_art(tail, meow, purr)
             self.draw_kitty(screen, kitty)
         if tail == 'left':
             tail = 'right'
             mylog.debug('Changed tail to %s' % tail)
         else:
             tail = 'left'
             mylog.debug('Changed tail to %s' % tail)
         ## Reset and adjust counters for the next kitty iteration ##
         current_line = 1
         self.kitty_time -= 1
         cute_count += 1
         meow = False
         purr_time = False
         purr = None
         cuteness = None
     screen.clear()
     ##  Return screen to previous sizesize ##
     if self.resize:
         print("\x1b[8;%s;%st" % (self.rows, self.columns))
     print "Kitty naptime!  Please come again!!"
コード例 #22
0
 def __init__(self):
     """
     Gets the screen from the colorconsole.terminal.
     """
     self.screen = terminal.get_terminal(conEmu=False)
コード例 #23
0
ファイル: solver.py プロジェクト: kapitanov/orbitals
 def print(self):
     """Вывод лога в консоль"""
     screen = terminal.get_terminal()
     for event in self._events:
         event.print(screen)
     screen.reset()
コード例 #24
0
ファイル: example2.py プロジェクト: actics/colorconsole
from __future__ import print_function
from colorconsole import terminal

screen = terminal.get_terminal(conEmu=False)
screen.clear()
screen.set_title("Example 2")

screen.print_at(0,0,"Color table")

if screen.type == "WIN":
    for x in range(16):
        screen.gotoXY(0,x+1)
        screen.cprint(15,0, "%2d"%x)
        screen.gotoXY(3,x+1)
        screen.cprint(x,x, " " * 20)
else:
    screen.gotoXY(0,3)
    for x in range(256):
        screen.xterm256_set_fg_color(x)
        print("%02x" % x, end="" if (x+1)%32!=0 else "\n")
        
    screen.gotoXY(0,12)
    for x in range(256):
        screen.xterm256_set_bk_color(x)
        print("%02x" % x, end="" if (x+1)%32!=0 else "\n")
    print()    
screen.reset_colors()

# Waits for a single key touch before ending.
screen.getch()
コード例 #25
0
import time
import datetime
import collections
from colorconsole import terminal
from func import resetcolor
from func import getdatefornextsaturday
from func import generatedatadictionary
from func import sethistory
from func import gethistory
from func import getstationnamefromfile
from func import getlatlonfromstation

history = "history.txt"

dow = datetime.datetime.today().weekday()
term = terminal.get_terminal(conEmu=False)
stations = generatedatadictionary()

cstations = collections.OrderedDict(sorted(stations.items()))

order = {}
count = 1
term.clear()
term.cprint(3, 0, '')
#print(str(cstations))
for key in cstations:
    order.update({count: cstations[key]})
    print("%s. %s" % (count, key))
    count += 1

#print(str(order))