Ejemplo n.º 1
0
def game_socket(ws):
    game = None
    while not ws.closed:
        message = ws.receive()
        if message == "new":
            game = Game()
            player_is = Game.random_player()
            print("New Game", player_is)
            if player_is == Tile.CIRCLE:
                result, _ = play_game(game)
            else:
                result = Result.NEXT_MOVE
            ws.send(generate_message(result, game.board))
        elif game and message:
            move = int(message)
            print("You play", move)
            result, lines = game.play(move)
            if result == Result.NEXT_MOVE:
                result, lines = play_game(game)
            elif result == Result.WON:
                print("finished")
                file.save(game.moves, game.currentPlayer)
            elif len(game.moves) == 9:
                print("finished")
                file.save(game.moves, None)

            ws.send(generate_message(result, game.board))
Ejemplo n.º 2
0
 def save_config(self, widget):
     print("Document saved")
     ts = time.time()
     timestamp = datetime.datetime.fromtimestamp(ts).strftime('%Y_%m_%d__%H_%M_%S.txt')
     initial = self.solution_grids[self.solution_grids_index]
     file.save("Solution_" + timestamp, initial, self.end_matrix)
     self.show_dialog("Archivo de configuracion guardado")
Ejemplo n.º 3
0
def save():
    global dirs
    global files
    global fileName
    global sysColor0
    global sysColor1
    file.save(dirs, files, fileName, sysColor0, sysColor1)
Ejemplo n.º 4
0
    def _display2pom(self, line_buffer):
        """
        Store line buffer, containing TODO tables to todo.pom

        Args: line_buffer - list of strings
        """
        line_buffer = [item + '\n' for item in line_buffer]
        file.save(line_buffer, self.settings['path_pom'], 'txt')
Ejemplo n.º 5
0
 def save_config(self, widget):
     print("Document saved")
     ts = time.time()
     timestamp = datetime.datetime.fromtimestamp(ts).strftime(
         '%Y_%m_%d__%H_%M_%S.txt')
     initial = self.solution_grids[self.solution_grids_index]
     file.save("Solution_" + timestamp, initial, self.end_matrix)
     self.show_dialog("Archivo de configuracion guardado")
Ejemplo n.º 6
0
def export(ballotToExport):

    # Add the ballot name to the export
    content = ballotToExport.title

    # Add the ballot address to the export
    content += "," + ballotToExport.address

    # Save the export
    file.save(ballotToExport.title + ' Export.csv', content)
Ejemplo n.º 7
0
    def __init__(self, root, puzzle_color_map, color_map):
        self.root = root
        self.camera = self.root.root.camera
        self.pg = self.root.root.pg
        self._render_queue = []

        json_color_map = {
            key: [self.root.current_palette[color] for color in data]
            for key, data in color_map.items()
        }
        save(json_color_map, puzzle_color_map)
Ejemplo n.º 8
0
    def save(self):
        import file
        import http.client
        from xml.etree import ElementTree

        
        number = self.input_C_number.toPlainText() 
        
        #get xml from object number
        key = "VZwF3B6OId9MZtOCoLO8pS5FCjIXGQj3MYkPenIahW0vcGzgC%2Bb8rJHcYoDRPk%2Fc9dsbldkOhJi0mBewN4UBMg%3D%3D"
        conn = http.client.HTTPConnection("data.ekape.or.kr")
        conn.request("GET", "/openapi-data/service/user/animalTrace/traceNoSearch?ServiceKey=" + key + "&traceNo=" + number) #서버에 GET 요청 

        req = conn.getresponse()    #openAPI 서버에서 보내온 요청을 받아옴
        cLen = bytearray(req.getheader("Content-Length"), 'utf-8')    #가져온 데이터 길이

        if int(req.status) == 200 :
            strXml = (req.read().decode('utf-8'))    #요청이 성공이면 book 정보 추출
            strList = ""
            tree = ElementTree.fromstring(strXml)
            
            itemElements = tree.getiterator("item")
            for item in itemElements:
                if (item.find("infoType")).text == "1" :
                    birthYmd = item.find("birthYmd")    #birthYmd 검색
                    cattleNo = item.find("cattleNo")    #cattleNo 검색
                    lsTypeNm = item.find("lsTypeNm")    #lsTypeNm 검색
                    sexNm = item.find("sexNm")          #sexNm 검색
        
                    strList += (str(birthYmd.text) + "\t" + str(cattleNo.text) + "\t" + str(lsTypeNm.text) + "\t" + str(sexNm.text) + "\n")
                
                if (item.find("infoType")).text == "2" :
                    farmAddr = item.find("farmAddr")    		#birthYmd 검색
                    farmerNm = item.find("farmerNm") 		#cattleNo 검색
                    regType = item.find("regType")
                    regYmd = item.find("regYmd")
        
                    strList += (str(farmAddr.text) + "\t" + str(farmerNm.text) + "\t" + str(regType.text) + "\t"+ str(regYmd.text) + "\n")
                
                if (item.find("infoType")).text == "3" :
                    butcheryYmd = item.find("butcheryYmd")              #butcheryYmd 검색
                    butcheryPlaceNm = item.find("butcheryPlaceNm")      #butcheryPlaceNm 검색
                    inspectPassYn = item.find("inspectPassYn")          #inspectPassYn 검색
                    
                    strList += (str(butcheryYmd.text) + "\t" + str(butcheryPlaceNm.text) + "\t" + str(inspectPassYn.text) + "\t")
                    
                if (item.find("infoType")).text == "4" :
                    processPlaceNm = item.find("processPlaceNm")         #processPlaceNm 검색
                    
                    strList += (str(processPlaceNm.text) + "\n")
                    
            file.save(strList)
Ejemplo n.º 9
0
 def save(self, path, *args):
     if args.__len__() < 1:
         for sample in self.get_sample_list():
             with open(path, "a") as f_obj:
                 json.dump(sample, f_obj, cls=ManifestEncoder)
                 f_obj.write('\n')
     else:
         if (args.__len__() < 3):
             raise ValueError("please input OBS path, ak, sk and endpoint.")
         manifest_json = []
         for sample in self.get_sample_list():
             manifest_json.append(json.dumps(sample, cls=ManifestEncoder))
         save(manifest_json, path, args[0], args[1], args[2])
Ejemplo n.º 10
0
def export(key, includePrivateKey=True):

    # Add the key name to the export
    content = key.name

    # Add the public key to the export
    content += "," + file.read('keys/public/' + key.name + '.csv')

    # Check if there is a corresponding private key and the user wanted to include it
    if includePrivateKey:

        # Add the private key to the export
        content += "," + file.read('keys/private/' + key.name + '.csv')

    # Save the export
    file.save(key.name + ' Export.csv', content)
Ejemplo n.º 11
0
def upload_file():
    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            print('no file')
            return redirect(request.url)
        file = request.files['file']
        # if user does not select file, browser also
        # submit a empty part without filename
        if file.filename == '':
            print('no filename')
            return redirect(request.url)
        else:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename), )
            print("Uploading")
    return render_template('index.html')
Ejemplo n.º 12
0
def saveKey(keyName, publicKey, privateKey=False):

    # Convert the public key object into an array
    publicKeyArray = [publicKey.n, publicKey.g]

    # Save the public key to the file system
    file.save('keys/public/' + keyName + '.csv',
              file.arrayToCsv(publicKeyArray))

    # Check if a private key was given
    if privateKey:

        # Convert the private key object into an array
        privateKeyArray = [privateKey.n, privateKey.phiN, privateKey.u]

        # Save the privte key to the file system
        file.save('keys/private/' + keyName + '.csv',
                  file.arrayToCsv(privateKeyArray))
Ejemplo n.º 13
0
 def _add_tasks2menu(self, tasks):
     todo_main_base_menu = file.load(self.settings['path_base_menu'],
                                     'json')
     children = []
     for task in tasks:
         bar = {
             "caption":
             task,
             "children": [{
                 "caption": "Short break",
                 "command": "todo_task_cmd",
                 "id": "todo_menu_short_break",
                 "args": {
                     "task": task,
                     "cmd": "short_break"
                 }
             }, {
                 "caption": "Long break",
                 "command": "todo_task_cmd",
                 "id": "todo_menu_long_break",
                 "args": {
                     "task": task,
                     "cmd": "long_break"
                 }
             }, {
                 "caption": "Ok",
                 "command": "todo_task_cmd",
                 "id": "todo_menu_ok",
                 "args": {
                     "task": task,
                     "cmd": "ok"
                 }
             }]
         }
         children.append(bar)
     tasks_menu = {"caption": "Tasks", 'children': children}
     todo_main_base_menu[0]['children'].insert(0, tasks_menu)
     file.save(todo_main_base_menu, self.settings['path_menu'], 'json')
     return
Ejemplo n.º 14
0
def saveBallot(title, address):

    # Save the ballot to the file system
    file.save('ballots/' + title + '.ballot', address)
Ejemplo n.º 15
0
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 11 14:46:10 2016

@author: Terminati
"""

import file
file.save("iroquois")
Ejemplo n.º 16
0
from file import save
from scipy.io import loadmat

dir = 'count/'

P = loadmat(dir + 'P.mat')['P']
P_tilde = loadmat(dir + 'P_tilde.mat')['P_tilde']
Fvec_tilde = loadmat(dir + 'Fvec_tilde.mat')['Fvec_tilde']

save(P, dir + 'P.pkl')
save(P_tilde, dir + 'P_tilde.pkl')
save(Fvec_tilde, dir + 'Fvec_tilde.pkl')