Example #1
0
 def __init__(self):
     self.log_manager = FileManager("log.csv",
                                    _default_log_values)
     self.command_manager = FileManager("commands.csv",
                                        _default_command_values)
     self.configuration_manager = FileManager("configuration.csv",
                                              _default_configuration_values)
    def getMatrixFromFile(self, name):
        fileManager = FileManager()
        matrixString = fileManager.getVectorTxt(name)

        matrix = self.__createMatrixArray(matrixString)

        return matrix
    def getVectorFromFile(self, name):
        fileManager = FileManager()
        vectorString = fileManager.getVectorTxt(name)

        vector = self.__createVectorArray(vectorString)

        return vector
Example #4
0
def index():
    now = datetime.datetime.now()
    ip = request.remote_addr

    pokemon = RandomPkmon().random_pkmon()
    info = pokemon["base_info"]
    stats = pokemon["statistic"]
    num = info["num"]
    name = info["name"]
    level = info["level"]
    moves = pokemon["moves"]
    dt = DamagesTimes()
    type_index1 = dt.get_type_index(info["type1"])
    type_index2 = dt.get_type_index(info["type2"])
    gifname = '%s.gif' % num
    # moves=pokemon["moves"]
    move_index1 = dt.get_type_index(moves["move1"]["type"])
    move_index2 = dt.get_type_index(moves["move2"]["type"])
    move_index3 = dt.get_type_index(moves["move3"]["type"])
    move_index4 = dt.get_type_index(moves["move4"]["type"])

    context = "%s 用户%s 遇到了 LV.%s %s" % (now, ip, level, name)
    FileManager().save2log(context)
    return render_template('index.html',
                           filename=gifname,
                           info=info,
                           pokemon=stats,
                           type_index1=type_index1,
                           type_index2=type_index2,
                           moves=moves,
                           move_index1=move_index1,
                           move_index2=move_index2,
                           move_index3=move_index3,
                           move_index4=move_index4)
Example #5
0
 def __init__(self, submission_data: SubmissionData, config: Config):
     self.submission_name: str = submission_data.name
     self.filename = submission_data.file_name  # TODO remove this dependency
     self.exe_name = config.exe_filename
     self.functions_data: List[FunctionData] = submission_data.functions
     self.path_manager = PathManager("submission-checker", submission_data,
                                     config)
     self.file_manager = FileManager(self.path_manager)
     self.input_handler = InputHandler(True)
Example #6
0
 def init_ci(self, path, is_local):
     self.logger = LogController()
     self.fileManager = FileManager(path)
     if not is_local:
         self.logger.header('generating env file...')
         self.ENV_FILE = self.get_env_content()
         self.fileManager.write_str(self.ENV_FILE)
         self.logger.greenText(f'Env file:\n{self.ENV_FILE}')
     else:
         self.logger.greenText('Running with env file local')
Example #7
0
    def battlewith(self, mypkmon, wild_pkmon):
        # 首先派出自己的精灵

        # 双方精灵加入战斗场景(写入文本文件)
        battle_manger = {'player': mypkmon, 'enemy': wild_pkmon}
        # print(battle_manger)
        # 测试获取的等级
        pkmoninfo = battle_manger["player"]["base_info"]
        print("该你上场了,去吧,%s!\n" % pkmoninfo['name'])
        FileManager().save_battle_env(battle_manger)
        BattleProcess().start(battle_manger)
        print("over")
Example #8
0
    def select(self, data, myself, aims):
        #
        move = None
        # 获取当前攻击方
        attacker = data[myself]["base_info"]
        pkmon_name = attacker["name"]

        battle_info = data[myself]["battle_info"]
        moves = battle_info["moves"]
        if myself == "player":

            # choose = int(input())
            choose = random.randint(1, 4)
            if choose == 1:
                move = 'move1'
            elif choose == 2:
                move = 'move2'
            elif choose == 3:
                move = 'move3'
            elif choose == 4:
                move = 'move4'
            else:
                print("啥都没做")
        else:
            move = "move" + str(random.randint(1, 4))
        # 选其中一个技能
        moveinfo = moves[move]
        print("%s使出了%s" % (pkmon_name, moveinfo["name"]))
        # 计算是否命中
        isHit = self.is_move_accuracy(moveinfo, data, myself, aims)
        if isHit is True:
            # 判断技能类型进行伤害计算后返回计算后的值
            data = self.move_effect(moveinfo, data, myself, aims)

        # 保存伤害计算结果
        FileManager().save_battle_env(data)
Example #9
0
        # Insert current date and time to spreadsheet.
        if data:
            newSheet.insert_row([str(datetime.now())], 2)

    # from the files that are downloaded, get them and put them in google sheets
    # assumption: the .csv files are deleted after inserted into google sheets.
    def putFilesInGoogleSheets(self, filemanager):
        content = filemanager.mergeCSVFiles().read()

        sheet = self.client.open('cryptoscreener')
        print(sheet)
        self.client.import_csv(sheet.id, content)


bot = TradingviewBot()
manager = FileManager()
sUpdater = SpreadsheetUpdater(bot.args['pair'])

print(bot.args['pair'])
# bot.signIn()
# print('Sign in stage completed')
#
# bot.downloadAll()
# print('download stage completed')

sUpdater.putFilesInGoogleSheets(manager)
print('Files in google sheets stage completed')

newSheet = sUpdater.openNewSheet()
sUpdater.searchAndCopy(newSheet, manager)
print('Search and copy stage completed')
Example #10
0
                # we had issues with this mainly for test 9.
                ESTR.resetESTR() 
                time.sleep(0.5)
                # send the desired test number to the ESTR
                COM.sendStr(item)

################################ MAIN LOOP ##########################################
printMenu()

# Make an object to represent the Stellaris and reset device.
ESTR = LoadTest()
ESTR.resetESTR()

# Create two log files. One for raw COM port data, the other
# for interpreted test results.
dataLog = FileManager("logs/datalog{}.txt")
resultLog = FileManager("logs/resultlog{}.txt")

#try to open the COM port to connect to ESTR
try:
    COM = Comms("COM39", 115200*2) #57600 #203400
except:
    quit_event.set()
    print("COM port could not be opened! Exiting...")

# Create a queue to communicate between COM producer thread
# and COM worker thread.
COMQueue = Queue.Queue()

# Create three daemom threads, one to read the COM port, one to 
# work on the COM data and the last to read the command line interface
Example #11
0
if args.path is None or \
        args.maillist is None or \
        args.timeDiff is None or \
        args.file is None or \
        args.screen is None or \
        args.siteName is None or \
        args.isCSV is None:
    print('One of the parameter missing.')
    sys.exit(0)

if os.path.isdir(args.path) is not True:
    print('Directory Not exist.')
    sys.exit(0)

f = FileManager()
f.setFile(args.file)


def sendMailtoDIH(screen=False, timeAhead=False):
    global emailtoDIH
    if not emailtoDIH:
        print('sending to dih')
        config = configparser.ConfigParser()
        config.read('./Config/mailList.ini')
        if config.has_section('dih.support'):
            senderList = [x[1] for x in config.items('dih.support')]
            config.clear()
            config.read('./Config/messages.cfg')
            messageList = [x[1] for x in config.items('dih.support')]
            service = Mail()