コード例 #1
0
	def __init__(self, size, playerOne, playerTwo):
		self.b = Board(size)
		self.size = self.b.getSize()
		self.playerOne = playerOne
		self.playerTwo = playerTwo
		self.winner = None
		self.currentPlayer = self.playerTwo # start on two as it moves onto one
		
		# change clear depending on operating system
		self.CLEAR = "cls"
		if syst() == 'Linux' or syst() == 'Mac':
			self.CLEAR = "clear"
コード例 #2
0
    def main():
        if syst() == "Windows":

            M = MainWindows()
            mode = input(
                "\n WHAT WOULD YOU LOVE TO DO?\n\t1)COPY Structure\n\t2)SAVE structure to Log\n\t3)LOAD structure from Log\n\t =>  "
            )
            print("\n")

            if mode == "1":
                M.drives("normal")
                if len(M.problems) > 0:
                    file = open(M.dest + "Problems.txt", "w", encoding="utf-8")
                    file.write("Problems found in coping structure: \n\n")
                    file.writelines(M.problems)
                    file.close()
                input("\n=======Done=======\n")
                rerun()
            elif mode == "2":
                M.drives("Unnormal")
                input("\n=======Done=======\n")
                rerun()
            elif mode == "3":
                # M.drives("load")
                M.logReader()
                input("\n=======Done=======\n")
                rerun()
            else:
                print(
                    "\nDidn't get it!!! What do you want to do?\nre-run the program if you were sure."
                )
コード例 #3
0
ファイル: vlcirc.py プロジェクト: jatchili/vlcirc
def ircstream():
  while True:
    data = irc.recv ( 4096 )
    print data # IRC channel data
    if 'End of /NAMES list' in data:
      print "Now, join the channel: http://webchat.freenode.net/?channels=%s channel, and type 'PLAY @2:00' to start video at 2:00." % irc_channel 
    if ('PLAY' in data):
      if 'PLAY @' in data:
        T = [int(t) for t in data.split('PLAY @')[1].split(' ')[0].split(':')]
        if len(T) == 3:
          time = T[0]*3600+T[1]*60+T[2]
        elif len(T) == 2:
          time = T[0]*60+T[1]
        elif len(T) == 1:
          time = T[0]
        else:
          time = 0
      else:
        time = 0
      if correction > 0:
        sleep(correction)
      # Linux
      if syst()=='Linux':
        system('vlc --start-time %s %s &' % (time,video_path))
      # Mac-OS
      elif syst()=='Darwin':
        if exists('/Applications/VLC.app/Contents/MacOS/VLC'):
          system('/Applications/VLC.app/Contents/MacOS/VLC --start-time %s %s &' % (time,video_path))
        else:
          versions = ['1.1.2', '1.1.3', '1.1.4', '1.1.4.1', '1.1.5', '1.1.6', '1.1.7', '1.1.8', '1.1.9', \
                      '2.0.0', '2.0.1', '2.0.2', '2.0.3', '2.0.4', '2.0.5', '2.0.6']
          # If your version is not here, more versions are: http://download.videolan.org/pub/videolan/vlc/
          for version in versions:
            if exists('/Volumes/vlc-%s/VLC.app/Contents/MacOS/VLC' % version):
              system('/Volumes/vlc-%s/VLC.app/Contents/MacOS/VLC --start-time %s %s &' % (version,time,video_path))
              break
      # Win-OS
      elif syst()=='Windows':
        if exists('C:\\Program Files\\VideoLAN\\VLC\\vlc.exe'):
            system('"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe" --start-time %s %s &' % (time,video_path))
        if exists('C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe'):
            system('"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe" --start-time %s %s &' % (time,video_path))
  pass
コード例 #4
0
                # endregion

                makedirs(path.dirname(self.dest + absulpath), exist_ok=True)
                with open(self.dest + absulpath + filename,
                          "w",
                          encoding="utf-8") as file:
                    file.write(toprint)
            except:
                self.problems.append(self.dest + absulpath + filename)
        print("end  : " + str(localtime().tm_min) + "\':" +
              str(localtime().tm_sec) + "\"")

    # endregion

if __name__ == "__main__":
    if syst() == "Windows":
        # region libs
        from os import environ
        from win32api import GetLogicalDrives
        from win32file import GetDriveType, DRIVE_FIXED, DRIVE_REMOVABLE
        #endregion

        M = MainWindows()
        M.usb_finder()
        mode = input(
            "WHAT WOULD YOU LOVE TO DO?\n1)COPY Structure\n2)SAVE structure to Log\n3)LOAD structure from Log\n > "
        )

        if mode == "1" or mode == "2":
            OS = input(
                "====\nDo you want to search OS drive\directories ?(yes\\no)\n > "
コード例 #5
0
from os import system, path
from time import sleep  # Imports asctime and sleep from time


def savefile(
):  # Creates a function (savefile()) with the code attached to it listed below
    game = open("m8ballresults.txt", "a")  # Opens results file for editing
    game.write(start), game.write("\n"), game.write(ask), game.write(
        "\n"), game.write(c), game.write("\n\n"), game.close(), print(
            "\nYour data has been saved.")
    sleep(1)  # Waits for one second


while 1:  # Initiates an infinite loop, until broken.
    c = ""
    if syst(
    ) == 'Windows':  # Checks if the operating system is Windows. If it is, it runs the 'cls' command. If not, it runs the 'clear' command. This clears the screen.
        system('cls')
    else:
        system('clear')
    print("Magic 8 Ball Slim V1".rjust(79))
    if not path.exists("m8ballresults.txt"):  # Checks for the results file
        file = open('m8ballresults.txt', "w"), file.close(
        )  # Creates new results file if not found by opening a new file, then closing it.
        print("New results file generated.")
    if not path.exists("m8ballusernames.txt"):  # Checks for the usernames file
        file2 = open('m8ballusernames.txt', "w"), file2.close()
        print("New usernames file generated."
              )  # If not found, it generates a new one.
    print(), print("Hello! Welcome to Magic 8 Ball - Python Edition!")
    start = input("What is your name? : ")  # Asks for your name
    if start in open('m8ballusernames.txt').read(
コード例 #6
0
    else:
        print("Uh oh, that was incorrect. The correct answer was: " + correct +
              "\n")


def endoftest():
    print("That's the end of the test. See you next time!")
    print("You scored: " + str(score))
    sleep(2)
    print("Saving data, please wait.", end='\r')
    savefile()
    print("Data saved successfully! ")
    sleep(2.5)
    exit()


while 1:
    if syst() == 'Windows':
        system('cls')
    else:
        system('clear')
    print("Welcome to the Unit 1 Quiz!")
    name = input("Please enter your name: ")
    print("Ah, hello " + name + "! Let's get this party started.")
    question(1, "What is a paradigm?", "A style or way of programming",
             "A series of memory locations", "A programming function",
             "A sandwich", "A")
    question(2, "What is a boolean?", "A numeric value", "True/False only",
             "True/False and strings", "A person that leans scarily", "B")
    endoftest()
コード例 #7
0
ファイル: vlcirc.py プロジェクト: Mindey/vlcirc
from sys import argv
from socket import socket, AF_INET, SOCK_STREAM
from os import system
from os.path import exists
from platform import system as syst
from time import sleep
import re
import urllib2

vlc_path = "vlc"
video_path = argv[1]
irc_nickname = "Ply" + str(int(random() * 10 ** 5))
irc_channel = argv[2]

# Linux
if syst() == "Linux":
    vlc_path = "vlc"

# Mac-OS
elif syst() == "Darwin":
    if exists("/Applications/VLC.app/Contents/MacOS/VLC"):
        vlc_path = "/Applications/VLC.app/Contents/MacOS/VLC"
    else:
        """ Try to retrieve path by checking possible versions """
        url = "http://download.videolan.org/pub/videolan/vlc/"
        versions = re.findall('(?<=")(\d+\.\d+\.\d+(?=/))', urllib2.urlopen(url).read())
        for version in versions:
            if exists("/Volumes/vlc-%s/VLC.app/Contents/MacOS/VLC" % version):
                vlc_path = "/Volumes/vlc-%s/VLC.app/Contents/MacOS/VLC" % version
                break