예제 #1
0
 def xsearch(self, query, access_token=None, per_page=10, page=1):
     """
     Search an Evis/Post/Article
     Usage: Evis.search('bon jovi OR metallica')
     Returns: generator object containing evis
     Eviscape API Method: evis.search
     """
     method = "evis.search"
     if access_token is None:
         data = request_get(method, q=query, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, q=query,\
                                      per_page=per_page, page=page)
     
     if FORMATTER == 'json':
         if isinstance(data.get('objects', None), list):
             for evi in data['objects']:
                 yield _parse_evis(evi)
     else:
         if data.rsp.objects.__dict__.has_key('evis'):
             if isinstance(data.rsp.objects.evis, list):
                 for evi in data.rsp.objects.evis:
                     yield _parse_evis(evi)
             else:
                 yield _parse_evis(data.rsp.objects.evis)
def accuracy():
    sort_type = 'date'
    page, keyword, so, so_list = request_get(request.args, sort_type=sort_type)
    paging, collection_list = get_accuracy_list(page=page, sort=so_list)
    data_list = []
    xlabels = []
    deep_dataset1 = []
    deep_dataset2 = []
    deep_dataset3 = []
    bay_dataset1 = []
    bay_dataset2 = []
    bay_dataset3 = []
    for data in collection_list:
        data_list.append(data)
        xlabels.append(data['date'])
        deep_dataset1.append(data['deep_accuracy'][0])
        deep_dataset2.append(data['deep_accuracy'][1])
        deep_dataset3.append(data['deep_accuracy'][2])
        bay_dataset1.append(data['bay_accuracy'][0])
        bay_dataset2.append(data['bay_accuracy'][1])
        bay_dataset3.append(data['bay_accuracy'][2])
    xlabels.reverse()
    deep_dataset1.reverse()
    deep_dataset2.reverse()
    deep_dataset3.reverse()
    bay_dataset1.reverse()
    bay_dataset2.reverse()
    bay_dataset3.reverse()

    sort_type = 'timestamp'
    return render_template('monitoring/accuracy.html', **locals())
def statistics():
    sort_type = 'date'
    page, keyword, so, so_list = request_get(request.args, sort_type=sort_type)
    accuracy_list, word_list = get_statistics_list()
    xlabels = []
    deep_dataset1 = []
    deep_dataset2 = []
    deep_dataset3 = []
    bay_dataset1 = []
    bay_dataset2 = []
    bay_dataset3 = []
    for data in accuracy_list:
        xlabels.append(data['date'])
        deep_dataset1.append(data['deep_accuracy'][0])
        deep_dataset2.append(data['deep_accuracy'][1])
        deep_dataset3.append(data['deep_accuracy'][2])
        bay_dataset1.append(data['bay_accuracy'][0])
        bay_dataset2.append(data['bay_accuracy'][1])
        bay_dataset3.append(data['bay_accuracy'][2])

    word_set = []
    count_set = []
    for data in word_list:
        word_set.append(data['word'])
        count_set.append(data['count'])
    return render_template('monitoring/statistics.html', **locals())


# render_template with multiple variables
# **locals() : https://stackoverflow.com/questions/12096522/render-template-with-multiple-variables
예제 #4
0
def summarize():
    report = Report()
    if request.method == 'POST':
        start = request.form['start']
        end = request.form['end']
        paging, data_list = report.summary(start=start, end=end)
        # https://github.com/Shir0kamii/Flask-CSV
        if data_list:
            encoding = 'utf-8-sig'
            filename = start + '_' + end + '.csv'
            buf = StringIO()
            writer = ValidatedWriter(buf, fieldnames=data_list[0].keys())
            writer.writeheader()
            for data in data_list:
                writer.writerow(data)
            buf.seek(0)
            buf = BytesIO(buf.read().encode(encoding))
            return send_file(buf,
                             attachment_filename=filename,
                             as_attachment=True,
                             mimetype='text/csv')
    form = PeriodSubmitForm()
    page, _, start, end = request_get(request.args)
    paging, data_list = report.summary(page=page, start=start, end=end)
    return render_template('report/summary.html', **locals())
예제 #5
0
def attend():
    report = Report()
    if request.method == 'POST':
        start = request.form['start']
        end = request.form['end']
        name = request.form['name']
        data_list = report.attend(page='all', name=name, start=start, end=end)
        if data_list:
            encoding = 'utf-8-sig'
            filename = start + '_' + end + '.csv'
            buf = StringIO()
            writer = ValidatedWriter(buf, fieldnames=data_list[0].keys())
            writer.writeheader()
            for data in data_list:
                writer.writerow(data)
            buf.seek(0)
            buf = BytesIO(buf.read().encode(encoding))
            return send_file(buf,
                             attachment_filename=filename,
                             as_attachment=True,
                             mimetype='text/csv')
    # https://gist.github.com/doobeh/3e685ef25fac7d03ded7#file-vort-html-L11
    form = PeriodSubmitForm()
    page, name, start, end = request_get(request.args)
    paging, today, data_list, summary = report.attend(page=page,
                                                      name=name,
                                                      start=start,
                                                      end=end)
    return render_template('report/attendance.html', **locals())
예제 #6
0
def word():
    sort_type = 'count'
    page, keyword, so, so_list = request_get(request.args, sort_type=sort_type)
    paging, data_list = get_word_list(page=page, sort=so_list, keyword=keyword)
    return render_template('word/word.html',
                           typo_synonym=typo_synonym,
                           **locals())
예제 #7
0
 def run(self):
     while self.runing:
         for tjbh in self.tjbhs:
             # for i in range(len(self.tjbhs)-1,-1,-1):
             # 中途暂停打印 处理
             if self.runing:
                 if self.is_remote:
                     # 网络打印
                     if api_print(tjbh, self.printer):
                         # 打印成功
                         self.signalCur.emit(tjbh, 1)
                     else:
                         # 打印失败
                         self.signalCur.emit(tjbh, 0)
                 else:
                     # 本地打印 需要下载
                     url = gol.get_value('api_report_down') % tjbh
                     filename = os.path.join(gol.get_value('path_tmp'),
                                             '%s.pdf' % tjbh)
                     if request_get(url, filename):
                         # 打印成功
                         if print_pdf_gsprint(filename) == 0:
                             # 打印成功
                             self.signalCur.emit(tjbh, 1)
                         else:
                             # 打印失败
                             self.signalCur.emit(tjbh, 0)
                     else:
                         # 打印失败
                         self.signalCur.emit(tjbh, 0)
             else:
                 return
         self.stop()
         self.signalExit.emit()
예제 #8
0
 def xreceived(self, member, node, access_token=None, per_page=10, page=1):
     """
     Get all received Evis/Post/Article of a Node/Profile/Evisite
     Usage: Evis.xreceived(Member(id=13), Nodes(id=17))
     Returns: A Generator with Evis Object
     Eviscape API Method: evis.received
     """
     method = "evis.received"
     if access_token is None:
         data = request_get(method, mem_id=member.id, nod_id=node.id, per_page=per_page, page=page)
     else:
         data = request_protected_get(
             method, access_token, mem_id=member.id, nod_id=node.id, per_page=per_page, page=page
         )
     if FORMATTER == "json":
         if isinstance(data.get("objects", None), list):
             for evi in data["objects"]:
                 yield _parse_evis(evi)
     else:
         if data.rsp.objects.__dict__.has_key("evis"):
             if isinstance(data.rsp.objects.evis, list):
                 for evi in data.rsp.objects.evis:
                     yield _parse_evis(evi)
             else:
                 yield _parse_evis(data.rsp.objects.evis)
예제 #9
0
def update_employee():
    form = EmployeeSubmitForm()
    employee = Employee()
    _, name, _, _ = request_get(request.args)
    if request.method == 'POST' and form.validate_on_submit():
        request_data = {
            'name': form.name.data,
            'department': form.department.data,
            'rank': form.rank.data
        }
        if form.employeeId.data:
            request_data['employeeId'] = int(form.employeeId.data)
        if form.beginDate.data:
            request_data['beginDate'] = form.beginDate.data.strftime(
                '%Y-%m-%d')
        if form.endDate.data:
            request_data['endDate'] = form.endDate.data.strftime('%Y-%m-%d')
        if form.email.data:
            request_data['email'] = form.email.data
        if form.regular.data:
            request_data['regular'] = form.regular.data
        if form.status.data:
            request_data['status'] = form.status.data
        employee.post(request_data)
        return redirect(url_for('main.employees'))
    data = employee.get(name=name)
    return render_template('user/update_employee.html', **locals())
예제 #10
0
def get_org_owners():
    """ Get the users who are listed as owners for the Docker org """
    url = "https://api.github.com/orgs/docker/members?role=admin"
    results = request_get(url)
    owners = []
    for result in results:
        owners.append(result.get('login'))
    return owners
예제 #11
0
def download_scoreboard(scoreboard_url, output_path):
    print 'Getting scoreboard from: %s' % scoreboard_url
    # request html
    html = utils.request_get(scoreboard_url)
    # save last table as dataframe
    df = utils.get_last_table(html)
    print 'Saving as csv at %s' % output_path
    # save df as csv
    utils.save_as_csv(df, output_path)
예제 #12
0
def download_submissoes(submissoes_url, output_path):
    print 'Getting submissions from: %s' % submissoes_url
    # request html
    html = utils.request_get(submissoes_url)
    # save last table as dataframe
    df = utils.get_last_table(html)
    print 'Saving as csv at %s' % output_path
    # save df as csv
    utils.save_as_csv(df, output_path)
예제 #13
0
def mystock():
    page, keyword, so = request_get(request.args)
    accountList = getAccountList()
    if accountList:
        account_num = accountList[0]
    else:
        account_num = None
    paging, data_list = getMyStock(account_num, page=page, is_paging=True)
    return render_template('stock/mystock.html', **locals())
예제 #14
0
def basic(request):
    return {
        'query':request_get(request, 'query', '', list_allowed=False),
        # TODO 这里需要个算法
        'hot_books':Book.objects.all()[:5],

        'taxonomys':Taxonomy.objects.filter(level=1,weight__gt=1)[:3],

    }
예제 #15
0
async def request(method, id, **params):
    r = request_get(f'https://api.genius.com/{method}/{id}',
                    params={
                        **params, 'access_token': genius_token
                    })
    j = await r.json()
    response_code = j['meta']['status']
    if response_code != 200:
        raise ValueError(f'request error code: {response_code}')
    return AttrDict(j)
예제 #16
0
def intent_detail(intent):
    form = IntentMessageForm()
    page, keyword, so, so_list = request_get(request.args)
    if request.method == 'POST' and form.validate_on_submit():
        request_data = {'msg': form.msg.data, 'intent': form.intent.data}
        post_intent(request_data)
    paging, data_list = get_intent_data_list(intent,
                                             page=page,
                                             keyword=keyword)
    return render_template('intent/intent_detail.html', **locals())
예제 #17
0
def signal():
    page, keyword, so = request_get(request.args)
    if keyword:
        paging, data_list = getSignal(page=page,
                                      codeName=keyword,
                                      so=so,
                                      is_paging=True)
    else:
        paging, data_list = getSignal(page=page, so=so, is_paging=True)
    return render_template('chart/signal.html', **locals())
예제 #18
0
def download_regions_champions_data(url, output_path_regional_champions):
    print 'Getting region champions from: %s' % url
    # request html
    html = utils.request_get(url)
    soup = BeautifulSoup(html, 'lxml')

    df_region_champs = generate_dataframes(url, soup,
                                           output_path_regional_champions)

    print 'Saving as csv at %s' % output_path_regional_champions
    utils.save_as_csv(df_region_champs, output_path_regional_champions)
def download_estatisticas(statistics_url, output_path):
    print 'Getting statistics from: %s' % statistics_url
    # request html
    html = utils.request_get(statistics_url)

    # save as dataframe
    # ignoreing first table because it is just the page header
    for df in pd.read_html(html)[1:len(pd.read_html(html))]:
        title = df.loc[0, 0].lower().replace(' ', '_')
        print 'Saving as csv at %s' % output_path + title + '.csv'
        # save df as csv
        utils.save_as_csv(df, output_path + title + '.csv')
예제 #20
0
def _list():
    form = IntentMessageForm()
    sort_type = 'count'
    page, keyword, so, so_list = request_get(request.args, sort_type=sort_type)
    if request.method == 'POST' and form.validate_on_submit():
        intent = form.intent.data
        request_data = {'intent': intent}
        post_intent(request_data)
    paging, data_list, data_len = get_intent_paging(page=page,
                                                    sort=so_list,
                                                    keyword=keyword)
    # data_len = data_list.count()
    return render_template('intent/intent_list.html', **locals())
예제 #21
0
 def search(self, q, per_page=10, page=1):
     """
     Search members on eviscape
     Usage: Members.search("deepak")
     Returns: List of Members object
     Eviscape API Method: members.search
     """
     method = "members.search"
     data = request_get(method, q=q, per_page=per_page, page=page)
     if FORMATTER == 'json':
         return _handle_member_json(data)
     else:
         return _handle_member_xml(data)
예제 #22
0
 def search(self, q, per_page=10, page=1):
     """
     Searches Nodes/Evisite/Profile on eviscape (public only)
     Usage: Nodes.search('iapain')
     Returns: List of Nodes object
     Eviscape API Method: nodes.search
     """
     method = "nodes.search"
     data = request_get(method, q=q, per_page=per_page, page=page)
     if FORMATTER == 'json':
         return _handle_node_json(data)
     else:
         return _handle_node_xml(data)
예제 #23
0
def chartSignal():
    page, keyword, so = request_get(request.args)
    data = get_code(codeName=keyword)
    data_list = []
    if data:
        codeName = keyword + ' (' + data['code'] + ')'
        data_list, buySignals, sellSignals = getChartSignal(data['code'],
                                                            type='bollinger',
                                                            so=so)
        if data_list:
            period = data_list[0]['date'] + ' ~ ' + data_list[-1]['date']
        else:
            period = ''
    return render_template('chart/chart_signal.html', **locals())
def monitoring():
    form = MonitoringForm()
    sort_type = 'timestamp'
    page, keyword, so, so_list = request_get(request.args, sort_type=sort_type)
    if request.method == 'POST' and form.validate_on_submit():
        category = form.category.data
        if category not in category_list and category != 'unknown':
            flash('there is no that kind of category')
        else:
            post_monitoring(timestamp=form.timestamp.data, category=category)
    paging, data_list = get_monitoring_data_list(page=page,
                                                 sort=so_list,
                                                 keyword=keyword)
    return render_template('monitoring/monitoring.html', **locals())
예제 #25
0
 def sent(self, node, access_token=None, per_page=100, page=1):
     """
     Get all posted Evis/Post/Article of a Node/Profile/Evisite
     Usage: Evis.sent(Nodes(id=17))
     Returns: A list of Evis Object
     Eviscape API Method: evis.sent
     """
     method = "evis.sent"
     if access_token is None:
         data = request_get(method, nod_id=node.id, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, nod_id=node.id, per_page=per_page, page=page)
     if FORMATTER == "json":
         return _handle_evis_json(data)
     else:
         return _handle_evis_xml(data)
예제 #26
0
def chart():
    page, keyword, so = request_get(request.args)
    data = get_code(codeName=keyword)
    if data:
        codeName = keyword + ' (' + data['code'] + ')'
        data_list = getChart(data['code'], isJson=True, so=so)
        if data_list:
            period = data_list[0]['date'] + ' ~ ' + data_list[-1]['date']
        else:
            period = ''
    else:
        keyword = '삼성전자'
        codeName = keyword + ' (005930)'
        data_list = getChart('005930', isJson=True, so=so)
        period = data_list[0]['date'] + ' ~ ' + data_list[-1]['date']
    return render_template('chart/chart.html', **locals())
예제 #27
0
 def speakers(self, access_token=None, per_page=10, page=1):
     """
     Get Nodes/Profile/Evisite which base node is Followering 
     Usage: Nodes(id=17).speakers()
     Returns: List of Nodes object
     Eviscape API Method: nodes.speakers
     """
     method = "nodes.speakers"
     if access_token is None:
         data = request_get(method, nod_id=self.id, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, nod_id=self.id, per_page=per_page, page=page)
     if FORMATTER == "json":
         return _handle_node_json(data)
     else:
         return _handle_node_xml(data)
예제 #28
0
 def get(self, access_token=None, per_page=10, page=1):
     """
     Get details of a Node/Profile/Evisite
     Usage: Nodes(id=17).get()
     Returns: Nodes object
     Eviscape API Method: node.get
     """
     method = "node.get"
     if access_token is None:
         data = request_get(method, nod_id=self.id, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, nod_id=self.id, per_page=per_page, page=page)
     if FORMATTER == "json":
         return _handle_node_json(data)[0]
     else:
         return _handle_node_xml(data)[0]
예제 #29
0
 def latest(self, access_token=None, per_page=10, page=1):
     """
     Get all latest Evis/Post/Article
     Usage: Evis.latest()
     Returns: A list with Evis Object
     Eviscape API Method: evis.latest
     """
     method = "evis.latest"
     if access_token is None:
         data = request_get(method, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, per_page=per_page, page=page)
     if FORMATTER == "json":
         return _handle_evis_json(data)
     else:
         return _handle_evis_xml(data)
예제 #30
0
 def created_by_member(self, member_name, access_token=None, per_page=10, page=1):
     """
     Get Node/Profile/Evisite which was created by User/Member
     Usage: Nodes.created_by_member("iapain")
     Returns: List of Nodes object
     Eviscape API Method: nodes.get
     """
     method = "nodes.get"
     if access_token is None:
         data = request_get(method, mem_name=member_name, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, mem_name=member_name, per_page=per_page, page=page)
     if FORMATTER == "json":
         return _handle_node_json(data)
     else:
         return _handle_node_xml(data)
예제 #31
0
 def get_for_member(self, member_name, perms='write', access_token=None, per_page=10, page=1):
     """
     Get Node/Profile/Evisite of a User/Member
     Usage: Nodes.get_for_memnber("iapain")
     Returns: List of Nodes object
     Eviscape API Method: nodes.get
     """
     method = "nodes.member"
     if access_token is None:
         data = request_get(method, mem_name=member_name, perms=perms, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, mem_name=member_name,\
                                       perms=perms, per_page=per_page, page=page)
     if FORMATTER == 'json':
         return _handle_node_json(data)
     else:
         return _handle_node_xml(data)
예제 #32
0
    def search(self, query, access_token=None, per_page=10, page=1):
        """
        Search an Evis/Post/Article
        Usage: Evis.search('bon jovi OR metallica')
        Returns: List of evis
        Eviscape API Method: evis.search
        """
        method = "evis.search"
        if access_token is None:
            data = request_get(method, q=query, per_page=per_page, page=page)
        else:
            data = request_protected_get(method, access_token, q=query, per_page=per_page, page=page)

        if FORMATTER == "json":
            return _handle_evis_json(data)
        else:
            return _handle_evis_xml(data)
예제 #33
0
def get_device():
    form = DeviceSubmitForm()
    devices = Device()
    if request.method == 'POST' and form.validate_on_submit():
        register_date = form.registerDate.data.strftime('%Y-%m-%d')
        end_date = form.endDate.data.strftime('%Y-%m-%d')
        request_data = {
            'mac': form.mac.data,
            'registerDate': register_date,
            'endDate': end_date,
            'owner': form.owner.data,
            'device': form.device.data
        }
        devices.post(request_data)
    page, _, _, _ = request_get(request.args)
    paging, data_list = devices.get(page=page)
    return render_template('user/device.html', **locals())
예제 #34
0
 def on_btn_report_down_click(self):
     filepath = QFileDialog.getExistingDirectory(
         self, "下载保存路径", desktop(),
         QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
     if not filepath:
         return
     button = mes_warn(self, "您确认下载当前选择的体检报告到路径:%s?" % filepath)
     if button != QMessageBox.Yes:
         return
     tjbh = self.gp_user.get_tjbh
     url = gol.get_value('api_report_down') % tjbh
     filename = os.path.join(filepath, '%s.pdf' % tjbh)
     if request_get(url, filename):
         # 下载成功
         mes_about(self, '下载成功!')
     else:
         mes_about(self, '未找到报告,无法下载!')
예제 #35
0
 def listeners(self, access_token=None, per_page=10, page=1):
     """
     Get Listeners/Followers of a Node/Profile/Evisite
     Usage: Nodes(id=17).listeners()
     Returns: List of Nodes object
     Eviscape API Method: nodes.listeners
     """
     method = "nodes.listeners"
     if access_token is None:
         data = request_get(method, nod_id=self.id, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, nod_id=self.id,\
                                      per_page=per_page, page=page)
     if FORMATTER == 'json':
         return _handle_node_json(data)
     else:
         return _handle_node_xml(data)
예제 #36
0
 def received(self, member, node, access_token=None, per_page=10, page=1):
     """
     Get all received Evis/Post/Article of a Node/Profile/Evisite
     Usage: Evis.received(Member(id=13), Nodes(id=17))
     Returns: A list with Evis Object
     Eviscape API Method: evis.received
     """
     method = "evis.received"
     if access_token is None:
         data = request_get(method, mem_id=member.id, nod_id=node.id, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, mem_id=member.id, nod_id=node.id,\
                                      per_page=per_page, page=page)
     if FORMATTER == 'json':
         return _handle_evis_json(data)
     else:
         return _handle_evis_xml(data)
def download_competidor_data(url, output_path_competitor, output_path_coach):
    global position
    position = 1
    print 'Getting competitors from: %s' % url
    # request html
    html = utils.request_get(url)
    soup = BeautifulSoup(html, 'lxml')

    df_competitors, df_coaches = generate_dataframes(url, soup,
                                                     output_path_competitor,
                                                     output_path_coach)

    print 'Saving as csv at %s' % output_path_competitor
    utils.save_as_csv(df_competitors, output_path_competitor)

    print 'Saving as csv at %s' % output_path_coach
    utils.save_as_csv(df_coaches, output_path_coach)
예제 #38
0
 def get(self, access_token=None, per_page=10, page=1):
     """
     Get an Evis/Post/Article
     Usage: Evis(id=6369).get()
     Returns: An Evis Object
     Eviscape API Method: evis.get
     """
     method = "evis.get"
     if access_token is None:
         data = request_get(method, evi_id=self.id, nod_id=self.node.id,\
                            per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, evi_id=self.id,\
                                      nod_id=self.node.id, per_page=per_page, page=page)
     if FORMATTER == 'json':
         return _handle_evis_json(data)[0]
     else:
         return _handle_evis_xml(data)[0]
예제 #39
0
 def get(self, node, evis, access_token=None, per_page=10, page=1):
     """
     Gets comments for an evis (optionally required access_token)
     Usage: Comments.get(Nodes(id=17), Evis(id=6259, Nodes(id=17))
     Returns: List of Comments object
     Eviscape API Method: comments.get
     """
     method = "comments.get"
     if access_token is None:
         data = request_get(method, nod_id=node.id, evi_id=evis.id,\
                            per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, nod_id=node.id,\
                                      evi_id=evis.id, per_page=per_page, page=page)
     if FORMATTER == 'json':
         return _handle_comment_json(data)
     else:
         return _handle_comment_xml(data)
예제 #40
0
def twofactorauth_check():
    """
    Make sure all user accounts have 2 factor auth enabled.
    """
    url = "https://api.github.com/orgs/docker/members?filter=2fa_disabled&per_page=200"
    result = request_get(url)
    naughty_list = []
    for res in result:
        login = res.get('login')
        if login not in BOTS:
            user = get_user(login)
            user_detail = {'login': login, 'name': user.get('name')}
            naughty_list.append(user_detail)

    print("The following people don't have 2FA turned on!")
    for baddy in naughty_list:
        print(" - {} -> {}".format(baddy.get('login'), baddy.get('name')))
    print("\n")
예제 #41
0
def get_members():
    count = 1
    """Creates a CSV file and writes the list of users into it"""
    with open('Github.csv', 'w') as f:
        writer = csv.writer(f)
        writer.writerow(["Github Handle", "User name", "Email"])
        while count <= 500:
            try:
                """ Get the users who are listed as owners for the Docker org """
                url = "https://api.github.com/orgs/docker/members?role=all&page={}&per_page=1".format(
                    count)
                result = request_get(url)
                grouping = []
                for res in result:
                    login = res.get('login')
                    if login not in BOTS:
                        user = get_user(login)
                        user_detail = {
                            'login': login,
                            'name': user.get(u'name'),
                            'email': user.get('email')
                        }
                        grouping.append(user_detail)

                for member in grouping:
                    print(" - {}, {}, {}".format(member.get('login'),
                                                 member.get(u'name'),
                                                 member.get('email')))
                    writer.writerow([
                        member.get('login'),
                        member.get(u'name'),
                        member.get('email')
                    ])
            except UnicodeEncodeError:
                username = member.get(u'name').encode('utf_32')
                s = username.decode('utf_32')
                print(" - {}, " + s + ", {}").format(member.get(u'login'),
                                                     member.get('email'))
                writer.writerow([
                    member.get('login'),
                    member.get(u'name').decode('utf_32'),
                    member.get('email')
                ])
            count += 1
예제 #42
0
 def get_files(self, access_token=None, per_page=10, page=1):
     """
     Get Files belongs to an Evis/Post/Article
     Usage: Evis(id=6369).get_files()
     Returns: A list of Files Object
     Eviscape API Method: evis.get_files
     """
     method = "evis.get_files"
     if access_token is None:
         data = request_get(method, evi_id=self.id, nod_id=self.node.id,\
                            per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, evi_id=self.id,\
                                      nod_id=self.node.id, per_page=per_page, page=page)
     if FORMATTER == 'json':
         self.files = _handle_file_json(data)
     else:
         self.files = _handle_file_xml(data)
     return self.files
예제 #43
0
 def on_btn_report_print_click(self):
     printerInfo = QPrinterInfo()
     default_printer = printerInfo.defaultPrinterName()
     button = mes_warn(self, "您确认用打印机:%s,打印当前选择的体检报告?" % default_printer)
     if button != QMessageBox.Yes:
         return
     tjbh = self.gp_user.get_tjbh
     # 本地打印 需要下载
     url = gol.get_value('api_report_down') % tjbh
     filename = os.path.join(gol.get_value('path_tmp'), '%s.pdf' % tjbh)
     if request_get(url, filename):
         # 打印成功
         if print_pdf_gsprint(filename) == 0:
             # 打印成功
             mes_about(self, '打印成功!')
         else:
             # 打印失败
             mes_about(self, '打印失败!')
     else:
         mes_about(self, '未找到可打印的报告!')
예제 #44
0
 def xlatest(self, access_token=None, per_page=10, page=1):
     """
     Get all latest evis
     Usage: Evis.xlatest()
     Returns: A Generator with Evis Object
     Eviscape API Method: evis.latest
     """
     method = "evis.latest"
     if access_token is None:
         data = request_get(method, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, per_page=per_page, page=page)
     if FORMATTER == "json":
         if isinstance(data.get("objects", None), list):
             for evi in data["objects"]:
                 yield _parse_evis(evi)
     else:
         if data.rsp.objects.__dict__.has_key("evis"):
             if isinstance(data.rsp.objects.evis, list):
                 for evi in data.rsp.objects.evis:
                     yield _parse_evis(evi)
             else:
                 yield _parse_evis(data.rsp.objects.evis)
예제 #45
0
 def xsent(self, node, access_token=None, per_page=10, page=1):
     """
     Get all posted Evis/Post/Article of a Node/Profile/Evisite
     Usage: Evis.xsent(Nodes(id=17))
     Returns: A Generator with Evis Object
     Eviscape API Method: evis.sent
     """
     method = "evis.sent"
     if access_token is None:
         data = request_get(method, nod_id=node.id, per_page=per_page, page=page)
     else:
         data = request_protected_get(method, access_token, nod_id=node.id,\
                                      per_page=per_page, page=page)
     if FORMATTER == 'json':
         if isinstance(data.get('objects', None), list):
             for evi in data['objects']:
                 yield _parse_evis(evi)
     else:
         if data.rsp.objects.__dict__.has_key('evis'):
             if isinstance(data.rsp.objects.evis, list):
                 for evi in data.rsp.objects.evis:
                     yield _parse_evis(evi)
             else:
                 yield _parse_evis(data.rsp.objects.evis)
예제 #46
0
def pre_words():
    sort_type = 'count'
    page, keyword, so, so_list = request_get(request.args, sort_type=sort_type)
    paging, data_list, keyword, useless_word_count = get_pre_words(
        page=page, sort=so_list, keyword=keyword)
    return render_template('word/pre_words.html', **locals())
예제 #47
0
def get_liquidity_pools():
    return request_get("/get_liquidity_pools", base_uri=REST_BASE_URI)
예제 #48
0
def get_blocks(limit: Optional[int] = 200):
    return request_get("/get_blocks",
                       base_uri=REST_BASE_URI,
                       params={"limit": limit})
예제 #49
0
def get_tokens():
    return request_get("/get_tokens", base_uri=REST_BASE_URI)