Ejemplo n.º 1
0
def _start_solve(job_id, solve_path, mesh_file_path, username, job_name, solve_app_type, solve_config):
    try:
        db = DB()
        so = SolveOpt(solve_dir=solve_path, solve_type=solve_app_type, mesh_file_path=mesh_file_path)
        so.ready_solve_dir(**solve_config)
        commands = so.get_commands_dict()
        total_core = None
        all_step = None
        options = solve_config["options"]
        for option_item in options:
            sub_options = option_item["option"]
            for sub_op in sub_options:
                if sub_op["name"] == "EXT_ITER":
                    all_step = sub_op["value"]
                if sub_op["name"] == "numProc":
                    total_core = sub_op["value"]
        if total_core <= 0:
            total_core = 10
        slurm = Slurm()
        slurm_id = slurm.send_job(work_dir=solve_path, total_core=total_core, username=username,
                                  job_name=job_name, **commands)
        log_file = str(Path(solve_path).joinpath(f"{slurm_id}.out"))
        error_file = str(Path(solve_path).joinpath(f"{slurm_id}.err"))
        db.write_solve_status(
            job_id=job_id,
            slurm_id=slurm_id,
            core_num=total_core,
            total_step=all_step,
            log_file=log_file,
            error_file=error_file
        )
        m_pid = DIR_MONITOR.create_watcher_process(solve_path, SU2ResultHandler(job_id))  # 监控文件夹
        return None
    except Exception:
        return "创建作业失败"
Ejemplo n.º 2
0
def stop_solve(solve_id):
    db = DB()
    slurm_id = db.query_solve_status(solve_id)["slurmId"]
    status = SlurmDB().query_job_status(slurm_id)
    if status is 0 or status is 1:
        solve_dir = DB().query_solve_path(solve_id)
        DIR_MONITOR.kill_watcher(solve_dir)
        Slurm.kill_job(slurm_id)
        core_logger.info(f"杀死杀死仿真作业 | slurm_id {slurm_id} | solve_id {solve_id}")
        return 0, "success"
    else:
        return 1, "the job has finished!"
Ejemplo n.º 3
0
    def _asyc_solve(self, solve_id):
        solve_app_type = CAE_APPLICATION_TYPE[self.solve_app]
        so = SolveOpt(self.work_path, solve_app_type=solve_app_type, mesh_file_path=self.mesh_file_name)
        so.ready_solve_dir(**self.solve_config)
        all_step = so.get_total_step()
        commands = so.get_commands_dict()
        slurm = Slurm()
        slurm_id = slurm.send_job(work_dir=self.work_path, total_core=self.core_num, username=self.username,
                                  job_name=self.job_name, **commands)
        log_file = str(Path(self.work_path).joinpath(f"{slurm_id}.out"))
        error_file = str(Path(self.work_path).joinpath(f"{slurm_id}.err"))
        DB.write_solve_status(
            job_id=solve_id,
            slurm_id=slurm_id,
            core_num=self.core_num,
            total_step=all_step,
            log_file=log_file,
            error_file=error_file
        )

        handler_cls = getattr(Handlers, MONITOR_HANDLERS_CLASSES_MAP[solve_app_type])
        m_pid = DIR_MONITOR.create_watcher_process(self.work_path, handler_cls(solve_id))  # 监控文件夹
        return None
Ejemplo n.º 4
0
def start_solve_actions(**params):
    solve_path = params["work-path"]
    launch_script = str(Path(solve_path).joinpath("solve.sh"))

    db = DB()
    job_id = db.write_solve(launch_script=launch_script, **params)  # 写入数据库
    if job_id == -1:
        return job_id, "写入数据库失败"
    excute_res = "创建仿真作业成功"

    # TODO: 开新的进程执行仿真操作
    mesh_file_name = params["mesh-file-name"]
    username = params["username"]
    solve_app_type = CAE_APPLICATION_TYPE[params["solve-app"]]
    solve_config = params["solve-config"]
    solve_config = json.loads(solve_config)
    job_name = params["job-name"]
    try:
        _start_solve(job_id, solve_path, mesh_file_name, username, job_name, solve_app_type, solve_config)
    except Exception:
        core_logger.exception("创建作业失败")
        excute_res = "创建作业失败"

    return job_id, excute_res
Ejemplo n.º 5
0
 def start_actions(self):
     core_logger.info(f"仿真信息写入数据库 | solve_app: {self.solve_app}"
                      f" | work_path: {self.work_path} | mesh_file_name: {self.mesh_file_name}"
                      f" | job_name: {self.job_name}")
     solve_id = DB.write_solve(work_path=self.work_path, mesh_file_name=self.mesh_file_name, username=self.username,
                               solve_app=self.solve_app, launch_script=self.launch_script,
                               solve_config=self.solve_config)
     if solve_id == -1:
         core_logger.info("写入数据库失败")
         return -1, "数据库写入失败"
     core_logger.info(f"创建进程执行仿真作业 | solve_id: {solve_id}")
     try:
         solve_pro = Process(target=self._asyc_solve, args=(solve_id,))
         solve_pro.start()
         core_logger.info(f"异步进行仿真 | solve_id: {solve_id}")
     except ProcessError:
         # TODO 更新solve的状态 数据库
         core_logger.exception(f"开启仿真进程失败 | solve_id: {solve_id}")
         return -1, "开启仿真进程失败"
     return solve_id, "sucess"
Ejemplo n.º 6
0
 def __init__(self):
     # DB组件
     self.DB = DB()
     # 日志组件
     self.logger = LoggerFactory.get_logger(threading.currentThread().name)
Ejemplo n.º 7
0
 def __init__(self):
     # 数据库操作组件
     self.DB = DB()
     # 日志组件
     self.logger = LoggerFactory.get_logger('create-article')
Ejemplo n.º 8
0
class CreateArticle(object):
    def __init__(self):
        # 数据库操作组件
        self.DB = DB()
        # 日志组件
        self.logger = LoggerFactory.get_logger('create-article')

    def write_file(self, file_path, content):
        ret = False
        f = None

        try:
            # 写入文件内容
            f = codecs.open(file_path, 'w', 'utf-8')
            f.write(content)
            f.close()

            ret = True
        except Exception as ex:
            self.logger.info(str(ex) + ':' + file_path)
        finally:
            if f:
                f.close()

        return ret

    def run(self, category, count_per_file):
        path = '/data/study/send_tasks/data/logs/md/20190423'

        self.DB.connect()
        try:
            sql = "select * from m_post_task where  status = 'success'  and selfCategory = '%s' order by id asc" % category
            tasks = self.DB.fetchall(sql)
            file_content = ''
            file_count = 0
            task_count = 0
            for task in tasks:
                title = "#### %s" % task.get('title')
                content = task.get('content')

                file_content += '%s\r\n%s\r\n\r\n' % (title, content)

                file_count += 1
                task_count += 1
                if file_count >= count_per_file:
                    # self.write_file('%s/%s-%d.txt' % (path, task.get('tags'), task_count // count_per_file), file_content)
                    self.write_file(
                        '%s/%s-%d(%s).txt' %
                        (path, task.get('tags'), task_count // count_per_file,
                         task.get('title')), file_content)
                    file_content = ''
                    file_count = 0

            if file_count:
                # self.write_file('%s/%s-%d.txt' % (path, task.get('tags'), task_count // count_per_file + 1), file_content)
                self.write_file(
                    '%s/%s-%d(%s).txt' % (path, task.get('tags'), task_count //
                                          count_per_file, task.get('title')),
                    file_content)
        except Exception as ex:
            self.DB.rollback()
            self.logger.exception(str(ex))
        finally:
            self.DB.close()
Ejemplo n.º 9
0
 def __init__(self):
     # 数据库操作组件
     self.DB = DB()
     # 日志组件
     self.logger = LoggerFactory.get_logger('db_import')
     pass
Ejemplo n.º 10
0
class ImportArticle(object):
    def __init__(self):
        # 数据库操作组件
        self.DB = DB()
        # 日志组件
        self.logger = LoggerFactory.get_logger('db_import')
        pass

    def read_file(self, file_path):
        """
        解析文件内容,取出标题和内容部分

        参数
        ----------------
        file_path:string
            文件绝对路径

        返回值
        ----------------
        dict
            文章标题和内容,如:{'title':'标题', 'content':'内容'}
        """

        f = None

        article = None

        try:
            ext = os.path.splitext(file_path)[1]
            if ext not in ['.txt', '.md', '.html', '.htm']:
                raise Exception('文件类型错误,只支持【md、html、htm】')

            # 读取文件内容
            f = codecs.open(file_path, 'r', 'utf-8')
            title = f.readline().strip('\n')
            content = f.read().strip('\n')
            f.close()

            # 对标题特殊字符过滤
            title = re.sub(r'<[^>]+>|#', '', title).strip()

            if ext in ['.md', '.txt']:
                # markdown 文件,内容需要转化成html
                content = markdown.markdown(content)

            article = {'title': title, 'content': content}
        except Exception as ex:
            self.logger.info(str(ex) + ':' + file_path)
        finally:
            if f:
                f.close()

        return article

    def get_plan_posttime(self, dict_date, count_per_day):
        """
        获取计划发布日期
        """
        curr_date = dict_date

        # 计算发布日期
        if curr_date['count'] >= count_per_day:
            # 开始下一个日期
            c_date = datetime.datetime.strptime(curr_date['date'], "%Y-%m-%d")
            n_date = (c_date + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
            curr_date['date'] = n_date
            curr_date['count'] = 0

        curr_date['count'] += 1

        return curr_date

    def run(self, file_dir, begin_date, count_per_day):
        """
        导入文章数据到表 m_post_task,m_post_task_platform

        参数
        ----------------
        file_dir: string
            文件目录
        begin_date:string
            开始发布日期,格式:2019-02-21
        num_per_day:int
            每天发布数量
        """
        # 存储从文件解析的内容
        articles = []

        # 初始发布日期
        dict_date = {'date': begin_date, 'count': 0}

        files = os.listdir(file_dir)
        for f in files:
            path = os.path.join(file_dir, f)
            if os.path.isfile(path):
                article = self.read_file(path)
                if article:
                    # 计算发布日期
                    dict_date = self.get_plan_posttime(dict_date,
                                                       count_per_day)

                    # 计划发布日期
                    article['planPostTime'] = dict_date['date']
                    articles.append(article)

        self.logger.info('需要导入的文章数量:%d' % len(articles))

        # 写数据库
        task_data = []
        for article in articles:
            article['slefCategory'] = '亲子阅读'
            article['tags'] = '亲子 互动'
            article['status'] = 'init'

            task_data.append((article['title'], article['slefCategory'],
                              article['tags'], article['content'],
                              article['status'], article['planPostTime']))

        # 写入表 m_post_task
        if task_data:
            self.DB.connect()
            task_sql = "insert into m_post_task(title, selfCategory, tags, content, status, planPostTime) values(%s, %s, %s, %s, %s, %s)"
            self.DB.executemany(task_sql, task_data)
            self.DB.commit()
            self.DB.close()

            self.logger.info('成功导入的文章数量:%d' % len(task_data))

        # 写入表 m_post_task_platform
        self.DB.connect()
        try:
            # 查询所有账户
            sql = 'select id, platformSn from m_platform_account where isEnable = 1'
            accounts = self.DB.fetchall(sql)

            # 查询所有未处理 post_task
            sql = 'select id from m_post_task where status = "init"'
            tasks = self.DB.fetchall(sql)

            data = []
            task_ids = ''
            for task in tasks:
                # 循环账户
                for account in accounts:
                    # 任务和账户关系数据是否存在
                    sql = "select id, status from m_post_task_platform where taskId = %d and accountId = %d" % (
                        task['id'], account['id'])
                    task_platform = self.DB.fetchone(sql)

                    if task_platform is None:
                        data.append((task['id'], account['platformSn'],
                                     account['id'], 'init'))
                        task_ids += ('%s,' % task['id'])

            # 需要更新任务ID
            task_ids = task_ids.rstrip(',')

            self.logger.info('需要导入的任务数量:%d' % len(data))

            sql = 'insert into m_post_task_platform(taskId, platformSn, accountId, status) values(%s, %s, %s, %s)'
            update_sql = 'update m_post_task set status = "success" where id in (%s)' % (
                task_ids)
            if data:
                self.DB.executemany(sql, data)
                self.DB.execute(update_sql)
                self.DB.commit()

                self.logger.info('成功导入的任务数量:%d' % len(data))
        except Exception as ex:
            self.DB.rollback()
            self.logger.exception(
                '写入表[m_post_task_platform],更新表[m_post_task]状态,异常:%s', str(ex))
        finally:
            self.DB.close()
Ejemplo n.º 11
0
 def __init__(self):
     self.DB = DB()
     pass
Ejemplo n.º 12
0
class DBinit(object):
    def __init__(self):
        self.DB = DB()
        pass

    def create_database(self):
        self.DB.connect(True)
        self.DB.execute(
            "CREATE DATABASE " + conf.env.DB_NAME +
            " DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci")
        self.DB.close()
        pass

    def create_tables(self):
        self.DB.connect()

        _sql = '''
        CREATE TABLE IF NOT EXISTS `anyun`.`m_platform` (
        `id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `sn` VARCHAR(30) NOT NULL COMMENT '平台编号',
        `name` VARCHAR(30) NOT NULL COMMENT '平台名称',
        `type` VARCHAR(30) NOT NULL DEFAULT 'post' COMMENT '类型(post-发布/get-爬取)',
        `homeUrl` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '平台首页',
        `sdkClass` VARCHAR(30) NOT NULL DEFAULT '' COMMENT 'SDK类名',
        `isEnable` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否可用',
        `createTIme` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`id`))
        ENGINE = InnoDB;
        '''
        rtn = self.DB.execute(_sql)

        _sql = '''
        CREATE TABLE IF NOT EXISTS `anyun`.`m_platform_account` (
        `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
        `platformSn` VARCHAR(30) NOT NULL COMMENT '平台编号',
        `platformName` VARCHAR(30) NOT NULL COMMENT '平台名称',
        `loginname` VARCHAR(30) NOT NULL COMMENT '登录名',
        `loginpass` VARCHAR(30) NOT NULL COMMENT '登录密码',
        `phoneNum` VARCHAR(11) NOT NULL COMMENT '手机号码',
        `isEnable` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否有效',
        `postUrl` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '发表博客URL',
        `createTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`id`))
        ENGINE = InnoDB;
        '''
        rtn = self.DB.execute(_sql)

        _sql = '''
        CREATE TABLE IF NOT EXISTS `anyun`.`m_post_task` (
        `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
        `title` VARCHAR(100) NOT NULL COMMENT '标题',
        `selfCategory` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '个人分类',
        `tags` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '标签',
        `content` TEXT NOT NULL COMMENT '内容',
        `status` VARCHAR(30) NOT NULL DEFAULT 'init' COMMENT '状态(init-初始/processing-处理中/success-成功/fail-失败)',
        `planPostTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '预定发布时间',
        `createTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`id`))
        ENGINE = InnoDB
        COMMENT = '发布任务表';
        '''
        rtn = self.DB.execute(_sql)

        _sql = '''
        CREATE TABLE IF NOT EXISTS `anyun`.`m_post_task_platform` (
        `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
        `taskId` INT NOT NULL COMMENT '任务ID',        
        `platformSn` VARCHAR(30) NOT NULL COMMENT '平台编号',
        `accountId` INT NOT NULL COMMENT '账户ID',
        `status` VARCHAR(30) NOT NULL DEFAULT 'init' COMMENT '状态(init-初始/processing-处理中/success-成功/fail-失败)',
        `detailUrl` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '详情页URL',
        `viewCount` INT NOT NULL DEFAULT 0 COMMENT '浏览数量',
        `lastViewTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后浏览时间',
        `createTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`id`))
        ENGINE = InnoDB;
        '''
        rtn = self.DB.execute(_sql)

        self.DB.close()

    def create_data(self):
        self.DB.connect()

        # # m_platform
        # _data = [
        #     ('sinablog', '新浪博客', 'post', 'http://blog.sina.com.cn/', 'SinaSDK', 1, time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S')),
        #     ('hexunblog', '和讯博客', 'post', 'http://blog.hexun.com/', 'HexunSDK', 1, time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S'))
        # ]
        # _sql = "insert into m_platform(sn, name, type, homeUrl, sdkClass, isEnable, createTime, updateTime) values(%s, %s, %s, %s, %s, %s, %s, %s)"
        # # _sql = "insert into m_platform(sn, name, type, homeUrl, sdkClass, isEnable, createTime, updateTime) values('sinablog','新浪博客', 'post', 'http://blog.sina.com.cn/', 'SinaSDK', 1, '2019-01-28 14:53:05', '2019-01-28 14:53:05')"
        # # self.DB.executemany(_sql, _data)

        # m_platform_account
        _data = [
            # ('sinablog', '新浪博客', '17611240182', 'asdf12#$', '17611240182', 1, 'http://control.blog.sina.com.cn/admin/article/article_add.php?is_new_editor=1', time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S')),
            # ('hexunblog', '和讯博客', '17611240182', 'asdf12#$', '17611240182', 1, 'http://post.blog.hexun.com/31122825/newpostblog.aspx', time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S')),
            # ('sinablog', '新浪博客', '17611258729', 'asdf12#$', '17611258729', 1, 'http://control.blog.sina.com.cn/admin/article/article_add.php?is_new_editor=1', time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S')),
            # ('hexunblog', '和讯博客', '17611258729', 'asdf12#$', '17611258729', 1, 'http://post.blog.hexun.com/31122834/newpostblog.aspx', time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S')),
            ('newsmth', '水木社区', 'wolala99', 'wo@999999', '19010001001', 1, 0,
             'http://www.newsmth.net/nForum/index',
             time.strftime('%Y-%m-%d %H:%M:%S'),
             time.strftime('%Y-%m-%d %H:%M:%S')),
            ('newsmth', '水木社区', 'love777777', 'love@8989', '19010001002', 1, 0,
             'http://www.newsmth.net/nForum/index',
             time.strftime('%Y-%m-%d %H:%M:%S'),
             time.strftime('%Y-%m-%d %H:%M:%S')),
            ('newsmth', '水木社区', 'wiccpp', 'ccc@66699', '19010001003', 1, 0,
             'http://www.newsmth.net/nForum/index',
             time.strftime('%Y-%m-%d %H:%M:%S'),
             time.strftime('%Y-%m-%d %H:%M:%S')),
            ('newsmth', '水木社区', 'xiifly', 'yyy@666666', '19010001004', 1, 0,
             'http://www.newsmth.net/nForum/index',
             time.strftime('%Y-%m-%d %H:%M:%S'),
             time.strftime('%Y-%m-%d %H:%M:%S')),
            ('newsmth', '水木社区', 'goodbbb', 'wo@999999', '19010001005', 1, 0,
             'http://www.newsmth.net/nForum/index',
             time.strftime('%Y-%m-%d %H:%M:%S'),
             time.strftime('%Y-%m-%d %H:%M:%S')),
            ('newsmth', '水木社区', 'xgggy', 'yyy@666666', '19010001006', 1, 0,
             'http://www.newsmth.net/nForum/index',
             time.strftime('%Y-%m-%d %H:%M:%S'),
             time.strftime('%Y-%m-%d %H:%M:%S')),
        ]
        _sql = "insert into m_platform_account(platformSn, platformName, loginname, loginpass, phoneNum, isEnable, isPost, postUrl, createTime, updateTime) values(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
        self.DB.executemany(_sql, _data)

        # # m_post_task
        # _content1 = '''
        # <div class="article-content"><p>有效能的亲子互动,不但拉近彼此的距离,也提升幼儿各项身心发展。不管多么忙碌,每天抽出一点时间陪伴孩子成长,或许你会从中获得不一样的惊喜。</p><div class="img-container"><img class="normal" data-loadfunc="0" src="https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3387886969,2427578226&amp;fm=173&amp;s=AE5005C706DA7BDED23CBC1E03001050&amp;w=400&amp;h=300&amp;img.JPEG" data-loaded="0" width="400px"></div><p><span class="bjh-strong"><span class="bjh-br"></span><span class="bjh-br"></span></span></p><p><span class="bjh-br"></span><span class="bjh-br"></span></p><p><span class="bjh-strong">亲子互动效益多</span></p><p>孩子的成长只有一次,每天短短的互动,不仅有助于孩子的发展,父母也可从中观察孩子的成长历程。“尤其当小朋友是给他人代为照顾时,更能清楚了解,孩子的发展进度跟照顾者所说明的是否符合,”台北市保母协会理事长何云凤特别提出说明。</p><p>现代人工作繁忙,家长与孩子间互动的频率、时间也随之减少,“每天至少要有2小时的互动,”何理事长建议。互动过程中的“质”比“量”更重要。父母应依自己的体力、时间、目的等,来做互动方式的安排。如果今天工作很累,可以跟宝宝进行简单的按摩、柔和的运动,等到精神、体力较充足时,再换以较动态的活动即可。</p><div class="img-container"><img class="normal" data-loadfunc="0" src="https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=4264143341,3950306581&amp;fm=173&amp;s=01C2DD155C63448A469DE0EE03007062&amp;w=400&amp;h=300&amp;img.JPEG" data-loaded="0" width="400px"></div><p>特别需要家长注意的是,在跟宝宝游戏的过程中,要以孩子的角色来陪伴孩子,让孩子把大人当做是他的同伴,尤其对于独生子女来说,可以从中同时学习如何与团体、同侪相处。</p><p><span class="bjh-strong">天马行空的创意</span></p><p>进行亲子互动前,建议父母先学习一些必要的知识及方法,让活动的效能更加的发挥作用,包括“语言、视觉的发展、大小肌肉的发育,以及各年龄的发展进程等,设计亲子互动模式之前,都应先考量及学习相关知识之后,再加以运用于整个过程,”何理事长建议家长。另外,针对孩子不同的特质、年龄、能力去设计互动的方式,是否可以引起他的兴趣,都是应该要衡量的要素。</p><p><span class="bjh-br"></span><span class="bjh-br"></span></p><p>游戏设计也可以未来将会学习、使用的知识或是技能为主,但要注意整个游戏的难易度、适龄性、实用性等。举例来说,3岁以下的小朋友并不懂图画书中的内容,但是爸爸妈妈可以利用书中的图片、游戏等的说明,进一步培养他的视力、色彩的辨别等的能力。当孩子已经达到现阶段的目标时,家长可适度的调整游戏的难度,让他的能力可以更往前迈进。</p><div class="img-container"><img class="normal" data-loadfunc="0" src="https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1082045148,730573433&amp;fm=173&amp;s=11227433457257845A5529E90300E022&amp;w=500&amp;h=333&amp;img.JPEG" data-loaded="0" width="500px"></div><p>“适时的加入创意元素,”是亲子互动里相当重要的一环,何理事长表示。游戏的过程中,当孩子表现预期外的行为,不妨鼓励孩子发挥创意、潜力,加入新的创意方式,跟孩子一起创造新的游戏方式,或是让游戏的方式更加的完美等,不要限制孩子创意及想象的空间。</p></div>
        # '''
        # _content2 = '''
        # <div class="article-content"><p><span class="bjh-p"></span></p><div class="img-container"><img class="large" data-loadfunc="0" src="http://t10.baidu.com/it/u=1148749497,629561652&amp;fm=173&amp;app=25&amp;f=JPEG?w=600&amp;h=86" data-loaded="0"></div><p><span class="bjh-p">大部分家长都知道亲子阅读是非常重要的亲子互动一步,不仅仅可以增进母子的关系,而且还可以提高孩子的认知能力,提高他们的阅读量以及思维空间。</span></p><div class="img-container"><img class="large" data-loadfunc="0" src="http://t10.baidu.com/it/u=3758561646,453416793&amp;fm=173&amp;app=25&amp;f=JPEG?w=590&amp;h=388&amp;s=D018AE7609D64EDA42DBE57C0300E07A" data-loaded="0"></div><p><span class="bjh-p"><span class="bjh-br"></span></span></p><p><span class="bjh-p">小编自从孩子一岁半岁左右就开始给他讲睡前故事。也让孩子养成一个固定的睡觉模式,那就是睡觉之前给他讲故事。现在孩子已经大概四周岁左右了,可以讲很多本故事书,认的字卡也超过一百字以上,并不是说小编在这里夸奖自己的孩子,而是想跟你们讲,每天坚持亲子阅读的话会有一个具有很多的好处。那么具体的好处又有哪些呢?下面小编来简单的说一下。</span></p><p><span class="bjh-h3">第一、增加母子之间的亲密度</span></p><p><span class="bjh-p">有时候小编在跟孩子讲故事的时候,我们有时候会针对故事里面的角色某一个行为而互相讨论,发表自己的看法。孩子有时候会看到这个故事搞笑的片段而哈哈大笑。这样子的行为,会让母子之间沟通起来更为的顺畅。以前孩子小的时候看的大多数是生字动画卡片,后来慢慢的就是小故事跟绘本。现在对于他来说故事并不是枯燥东西,而是一件有趣的事情。</span></p><div class="img-container"><img class="large" data-loadfunc="0" src="http://t10.baidu.com/it/u=2062643019,234929117&amp;fm=173&amp;app=25&amp;f=JPEG?w=597&amp;h=390&amp;s=F01AAE761D5255CE1AD9807A0300607B" data-loaded="0"></div><p><span class="bjh-p"><span class="bjh-br"></span></span></p><p><span class="bjh-h3">第二、讲故事也是另一种教育方式</span></p><p><span class="bjh-p">小编并没有针对性的听某些教育专家购买哪些故事,而是带孩子自己去书店,让孩子自主选择他自己所感兴趣的绘本,然后再从中讲解。小编最喜欢买的故事书,那就是睡前故事。而通过讲睡前故事,小编有时候会对孩子错误的行为善加引导,比如说老师说孩子在幼儿园犯了什么错误,那么小编就会跟孩子讲他的行为是不是跟故事里面的某一个人物的行为是一样的呢?如果他在持续这样子做的话,那么他会跟故事里面的某一个角色一样都是不受欢迎的。这样子教育的话更加的轻松。</span></p><div class="img-container"><img class="normal" data-loadfunc="0" src="http://t12.baidu.com/it/u=3631860536,3538924131&amp;fm=173&amp;app=25&amp;f=JPEG?w=519&amp;h=305&amp;s=7C28BE5741506DCE52FF386803005038" data-loaded="0" width="519px"></div><p><span class="bjh-p"><span class="bjh-br"></span></span></p><p><span class="bjh-h3">第三、就是培养孩子自己固定的一个睡眠模式</span></p><p><span class="bjh-p">一般小编给孩子讲故事,都是讲睡前故事的。那么在之前小编就会让他自己把所有的玩具收拾好,下一步自己去刷牙洗脸。这样子他自己就会养成一个固定的睡觉模式。如果我要听故事了,那么我现在要做的就是一些准备的行为。他自己会有意识地把这些行为都给完成,所以说读故事的话可以利于他们培养自己的时间观念和行为能力。</span></p><div class="img-container"><img class="large" data-loadfunc="0" src="http://t10.baidu.com/it/u=3977658180,3573518034&amp;fm=173&amp;app=25&amp;f=JPEG?w=640&amp;h=480&amp;s=B09AAF77D3ABC54D024B2C690300E078" data-loaded="0"></div><p><span class="bjh-p"><span class="bjh-br"></span></span></p><p><span class="bjh-p">作为妈妈的你,有留出和孩子的亲子阅读时间吗?你有哪些新颖的方式呢?一起交流一下帮助孩子们共同成长!<span class="bjh-br"></span></span></p><p><span class="bjh-p"><span class="bjh-br"></span></span></p><p><span class="bjh-p"><span class="bjh-br"></span></span></p><p><span class="bjh-p"></span></p></div>
        # '''
        # _data = [
        #     ('父母须知——亲子互动好处多', '亲子阅读', '亲子 互动', _content1, 'init', time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S')),
        #     ('亲子阅读这三大好处,聪明的父母都应该这么做!', '亲子阅读', '亲子 互动', _content2, 'init', time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S'), time.strftime('%Y-%m-%d %H:%M:%S'))
        # ]
        # _sql = "insert into m_post_task(title, selfCategory, tags, content, status, planPostTime, createTime, updateTime) values(%s, %s, %s, %s, %s, %s, %s, %s)"
        # # self.DB.executemany(_sql, _data)

        self.DB.commit()
        self.DB.close()
Ejemplo n.º 13
0
# -*- coding=utf-8 -*-
Ejemplo n.º 14
0
from flask import request, jsonify, json