コード例 #1
0
def ReadLines():
    lines = []
    line = Console.ReadLine()
    while line is not None:
        lines.append(line)
        line = Console.ReadLine()
    return lines
コード例 #2
0
def Read():
    try:
        with con:
            cur.execute("SELECT * FROM SPILLER ORDER BY SCORE DESC") # Indholdet hentes
            rows=cur.fetchall() # resultatet gemmes i variablen rows
            for row in rows:
                Console.WriteLine(row)
    except:
        Console.WriteLine("Failed to get highscores from database")
コード例 #3
0
def Attack(self):
    if (self._windup):
        Console.WriteLine("You swing your {0} and deal {1} damage", self._name,
                          self._damage)
        self._windup = False
        return self._damage
    else:
        self._windup = True
        Console.WriteLine("You ready your {0}", self._name)
        return 0
コード例 #4
0
def CDREventArrived(sender, e):
    ##Get the Event object and display it
    pd = e.NewEvent.Properties["TargetInstance"]
    mbo = pd.Value
    if (mbo.Properties["VolumeName"].Value is not None):
        titleRetriever = TitleRetriever(mbo.Properties["DeviceID"].Value[0:1])
        movieName = titleRetriever.getMovieName()
        Console.WriteLine("Found: "+movieName)
        notifier.showBalloon("Begining Archive",movieName)

        mkvFile = ripper.rip(titleRetriever.driveLetter, movieName)
        ripper.transcode(mkvFile, movieName)
    else:
        notifier.showBalloon("Disk Ejected")
        Console.WriteLine("CD has been ejected")
コード例 #5
0
 def __update_input(self):
     mapping = defaultdict(lambda: None, 
                           {ConsoleKey.A:Snake.left,ConsoleKey.J:Snake.left, ConsoleKey.LeftArrow:Snake.left,
                            ConsoleKey.D:Snake.right,ConsoleKey.L:Snake.right,ConsoleKey.RightArrow:Snake.right,
                            ConsoleKey.W:Snake.up,ConsoleKey.I:Snake.up,ConsoleKey.UpArrow:Snake.up,
                            ConsoleKey.S:Snake.down,ConsoleKey.K:Snake.down,ConsoleKey.DownArrow:Snake.down})
     while True: self.last_input = mapping[Console.ReadKey(True).Key]
コード例 #6
0
 def _input_breakpoint(self, keyinfo):
     keyinfo2 = Console.ReadKey()
     if keyinfo2.Key in IPyDebugProcess._breakpointcmds:
         return IPyDebugProcess._breakpointcmds[keyinfo2.Key](self,
                                                              keyinfo2)
     else:
         print "\nInvalid breakpoint command", str(keyinfo2.Key)
         return False
コード例 #7
0
def Attack(self):
    if self._windup == False:
        self._windup = True
        Console.WriteLine("The enemy attacks for {0} damage", self._damage)
        return self._damage
    else:
        print("The enemy is winding up!")
        self._windup = False
        return 0
コード例 #8
0
def Block(self, damage):

    Console.WriteLine(
        "You defend yourself with your {0}, it blocks {1} damage", self._name,
        self._block)

    if (self._block < damage):
        return damage - self._block
    else:
        return 0
コード例 #9
0
    def _bp_add(self, keyinfo):
        try:
            args = Console.ReadLine().Trim().split(':')
            if len(args) != 2: raise Exception, "Only pass two arguments"
            linenum = int(args[1])

            for assm in self.active_appdomain.Assemblies:
                for mod in assm.Modules:
                    bp = create_breakpoint(mod, args[0], linenum)
                    if bp != None:
                        self.breakpoints.append(bp)
                        bp.Activate(True)
                        Console.WriteLine("Breakpoint set")
                        return False
            raise Exception, "Couldn't find %s:%d" % (args[0], linenum)

        except Exception, msg:
            with CC.Red:
                print "Add breakpoint failed", msg
コード例 #10
0
ファイル: Basic.py プロジェクト: wuyasec/inVtero.net
def db(p, addr, len=128, maxWid = 64):
    if Console.WindowWidth-4 < maxWid:
        maxWid = Console.WindowWidth-4
    words = p.GetVirtualByteLen(addr, len)
    curr = 0
    while curr < len:
        Misc.WxColor(ConsoleColor.White, ConsoleColor.Black, VIRTUAL_ADDRESS(addr+curr).xStr + " ")
        while curr < len and Console.CursorLeft < maxWid:
            Misc.WxColor(ConsoleColor.Green, ConsoleColor.Black, words[curr].ToString("x2") + " ")
            curr = curr+1
        Console.Write(Environment.NewLine);
コード例 #11
0
ファイル: Basic.py プロジェクト: wuyasec/inVtero.net
def ds(p, addr, len=128, maxWid = 72):
    if Console.WindowWidth-4 < maxWid:
        maxWid = Console.WindowWidth-4
    words = p.GetVirtualLongLen(addr, len)
    len = len / 8
    curr = 0
    while curr < len:
        Misc.WxColor(ConsoleColor.White, ConsoleColor.Black, VIRTUAL_ADDRESS(addr+(curr*8)).xStr + " ")
        Misc.WxColor(ConsoleColor.Green, ConsoleColor.Black, words[curr].ToString("x16") + " ")
        Misc.WxColor(ConsoleColor.Cyan, ConsoleColor.Black, "[" +  p.GetSymName(words[curr]) + "]")
        curr = curr+1
        Console.Write(Environment.NewLine);
コード例 #12
0
    def _input(self):
        offset, sp = get_frame_location(self.active_thread.ActiveFrame)
        lines = self._get_file(sp.doc.URL)
        self._print_source_line(sp, lines)

        while True:
            print "ipydbg» ",
            keyinfo = Console.ReadKey()
            if keyinfo.Key in IPyDebugProcess._inputcmds:
                if IPyDebugProcess._inputcmds[keyinfo.Key](self, keyinfo):
                    return
            else:
                print "\nPlease enter a valid command"
コード例 #13
0
    def _set_bp_status(self, activate):
        stat = "Enable" if activate else "Disable"
        try:
            bp_num = int(Console.ReadLine())
            for i, bp in enumerate(self.breakpoints):
                if i + 1 == bp_num:
                    bp.Activate(activate)
                    print "\nBreakpoint %d %sd" % (bp_num, stat)
                    return False
            raise Exception, "Breakpoint %d not found" % bp_num

        except Exception, msg:
            with CC.Red:
                print "&s breakpoint Failed %s" % (stat, msg)
コード例 #14
0
    def _input_repl_cmd(self, keyinfo):
        with CC.Gray:
            print "\nREPL Console\nPress Ctl-Z to Exit"
            cmd = ""
            _locals = {'self': self}

            while True:
                Console.Write(">>>" if not cmd else "...")

                line = Console.ReadLine()
                if line == None:
                    break

                if line:
                    cmd = cmd + line + "\n"
                else:
                    try:
                        if len(cmd) > 0:
                            exec compile(cmd, "<input>",
                                         "single") in globals(), _locals
                    except Exception, ex:
                        with CC.Red:
                            print type(ex), ex
                    cmd = ""
コード例 #15
0
ファイル: Basic.py プロジェクト: sean-lab/inVtero.net
def db(p, addr, len=128, bytesPerLine=16):
    words = p.GetVirtualByteLen(addr, len)
    curr = 0
    while curr < len:
        Misc.WxColor(ConsoleColor.White, ConsoleColor.Black,
                     VIRTUAL_ADDRESS(addr + curr).xStr + " ")
        for c in range(0, bytesPerLine):
            Misc.WxColor(ConsoleColor.Green, ConsoleColor.Black,
                         words[curr + c].ToString("x2") + " ")
        for ch in range(0, bytesPerLine):
            myChar = Encoding.ASCII.GetString(words, curr + ch, 1)[0]
            #if Char.IsLetterOrDigit(myChar) == False:
            #    myChar = " "
            Misc.WxColor(ConsoleColor.Cyan, ConsoleColor.Black, myChar)
        Console.Write(Environment.NewLine)
        curr = curr + bytesPerLine
コード例 #16
0
    def _print_source_line(self, sp, lines):
        linecount = len(lines)
        linecount_fmt = "%%%dd: " % len(str(linecount))

        for i in range(sp.start_line, sp.end_line + 1):
            with CC.Cyan:
                Console.Write(linecount_fmt % i)
            line = lines[i - 1] if i <= linecount else ""
            start = sp.start_col if i == sp.start_line else 1
            end = sp.end_col if i == sp.end_line else len(line) + 1

            with CC.Gray:
                Console.Write(line.Substring(0, start - 1))
                with CC.Yellow:
                    Console.Write(line.Substring(start - 1, end - start))
                Console.Write(line.Substring(end - 1))

            if sp.start_line == sp.end_line == i and sp.start_col == sp.end_col:
                with CC.Yellow:
                    Console.Write(" ^^^")
            Console.WriteLine()
コード例 #17
0
 def testInBase(self):
     Console.WriteLine("--testInBase--")
     Assert.IsTrue(True)
コード例 #18
0
 def testPass(self):
     Console.WriteLine("--testPass--")
     Assert.IsTrue(True)
コード例 #19
0
 def testFail(self):
     Console.WriteLine("--testFail--")
     Assert.IsTrue(False, "this will fail")
コード例 #20
0
from System.Reflection import Assembly
from System.Text import Encoding
from System import Array, Object, String, Convert, Console
from System.IO import StreamWriter, MemoryStream

encoded_assembly = "ASSEMBLY_BASE64"

assembly = Assembly.Load(Convert.FromBase64String(encoded_assembly))
args = Array[Object]([Array[String](["ARGS"])])

# For some reason if we don't set the console output back to stdout after executing the assembly IronPython throws a fit
orig_out = Console.Out
orig_error = Console.Error

with MemoryStream() as ms:
    with StreamWriter(ms) as sw:
        Console.SetOut(sw)
        Console.SetError(sw)
        assembly.EntryPoint.Invoke(None, args)
        sw.Flush()
        buffer = ms.ToArray()
        print Encoding.UTF8.GetString(buffer, 0, buffer.Length)
        Console.SetOut(orig_out)
        Console.SetError(orig_error)
コード例 #21
0
ファイル: net_console.py プロジェクト: snapiri/slides
import clr
from System import Console

Console.WriteLine("Hello My World!")
コード例 #22
0
# -*- coding: utf-8 -*-

# clrをインポートして、System.Windows.Forms.dllを参照に追加
import clr
clr.AddReferenceByPartialName("System.Windows.Forms")

# System.Windows.Forms名前空間からMessageBoxクラスをインポートして
# そのMessageBoxクラスを使ってメッセージ・ボックスを表示
from System.Windows.Forms import MessageBox
MessageBox.Show("Hello IronPython!", "Insider.NET") 

from System import Console
Console.WriteLine(u"あいうえお(Console版)")

'''
How to run

1. Download IronPython-2.7.7-win.zip
1. Extract zip
1. Set full path of extracted(installed) folder into PATH environment variable.
1. Type following command in terminal.
    ipy hello_ironpython.py
'''
コード例 #23
0
def Add(name,score,time):
    try:
        with con:       
            cur.execute("INSERT INTO SPILLER (Id,name,score,time) VALUES(NULL,?,?,?)",(name,score,time))
    except:
        Console.WriteLine("Failed to add player to the highscore database")
コード例 #24
0
ファイル: AI.py プロジェクト: ekolis/FrEee
import FrEee
import FrEee.Utility
from FrEee.Game.Objects.Commands import *
clr.ImportExtensions(FrEee.Utility.Extensions)
from System import Console

# alias the domain and context variables to avoid confusion
empire = domain
galaxy = context

# TODO - Design Managment ministers
# TODO - Colony Management ministers
if (enabledMinisters.ContainsKey("Empire Management")):
    category = enabledMinisters["Empire Management"]
    if (category.Contains("Research")):
        # choose what to research
        # TODO - actually choose sensibly, don't always research Propulsion
        cmd = ResearchCommand()
        cmd.Spending[Mod.Current.Technologies.FindByName("Propulsion")] = 100
        empire.ResearchCommand = cmd
    # TODO - check for more ministers and execute their code
# TODO - Vehicle Managment ministers

# test AI data storage
if (not empire.AINotes.HasProperty("Log")):
    empire.AINotes.Log = []
empire.AINotes.Log.Add("{0} has played its turn for stardate {1}.\n".format(
    empire.Name, galaxy.Stardate))
for msg in empire.AINotes.Log:
    Console.WriteLine(msg)
コード例 #25
0
### Quicky REPL
###
import clr
from System import Console
from System.IO import StringReader

input = None
exprstr = ""
prompt = ">>> "
print "\n" * 3
print "Enter expressions.  Enter blank line to abort input."
print "Enter 'exit (the symbol) to exit."
print "\n"
while True:
    print prompt,
    input = Console.ReadLine()
    if (input == ""):
        exprstr = ""
        prompt = ">>> "
        continue
    else:
        exprstr = exprstr + " " + input
    ## See if we have complete input.
    try:
        sympl.parser.ParseExpr(StringReader(exprstr))
    except Exception, e:
        prompt = "... "
        continue
    ## We do, so execute.
    try:
        res = s.ExecuteExpr(exprstr, feo)
コード例 #26
0
 def __show(self,left,top,color,content): Console.CursorLeft = left; Console.CursorTop = top; Console.BackgroundColor = color; Console.Write(content)
 def show_score(self,score): self.__show(3,23,Screen.black,"Score:  {0}".format(score))
コード例 #27
0
def ReadLine():
    return Console.ReadLine()
コード例 #28
0
def WaitForSpaceBarKeyPress():
    while True:
        keyInfo = Console.ReadKey(True)
        if keyInfo.Key == ConsoleKey.Spacebar:
            break
    return
コード例 #29
0
    cur = con.cursor()

    cur.execute("Select * from Player")
    rows = cur.fetchall()
    print ""
    i = 0  #Number of rows
    for row in rows:
        print "Save ID", row[0]
        print "Save Name", row[1]
        print "Save Money", row[2]
        print ""
        i += 1

    while True:
        Console.WriteLine("Select a save file (Write the ID number)")
        playerinput = Console.ReadLine()
        try:
            if int(playerinput) < i + 1 and int(playerinput) > 0:
                break
            else:
                print "Please enter something valid"
        except ValueError:
            print "Please enter something valid"

    with con:
        cur.execute("Select * from Player where Id = " + playerinput)
    playersave = cur.fetchall()
    for row in playersave:
        playerId = row[0]
        playerName = row[1]
コード例 #30
0
ファイル: UpdateDatabase.py プロジェクト: Sundanian/Casino
import sqlite3 as lite
import sys
from System import Console

con = None

Console.WriteLine("Saving...")


def Update(id, money):
    try:
        con = lite.connect('Users.db')
        cur = con.cursor()

        with con:
            cur.execute("UPDATE Player SET Money = " + money + " WHERE Id = " +
                        id)

    except lite.Error, e:
        print "Error %s:" % e.args[0]
        sys.exit(1)

    finally:
        if con:
            con.close()