• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utilities.print_message函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.utilities.print_message函数的典型用法代码示例。如果您正苦于以下问题:Python print_message函数的具体用法?Python print_message怎么用?Python print_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了print_message函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: logon

def logon(request):
    credential = {
        'username': request.GET.get('username'),
        'password': request.GET.get('password')
    }
    if not credential['username']:
        print "[-] No username in logon request"
        return HttpResponse(status=403)
    elif not credential['password']:
        print "[-] No password in logon request"
        return HttpResponse(status=403)

    lm = LogonManager()
    bootstrap = False
    if not os.path.exists(ESGF_CREDENTIALS):
        bootstrap = True
    try:
        lm.logon_with_openid(credential['username'], credential['password'], bootstrap=bootstrap)
    except Exception as e:
        print_message('Unable to log in user {}'.format(credential.get('username')))
        return HttpResponse(status=403)
    if lm.is_logged_on():
        return HttpResponse(status=200)
    else:
        return HttpResponse(status=403)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:25,代码来源:views.py


示例2: read_output_script

def read_output_script(request):
    script_name = request.GET.get('script_name')
    run_name = request.GET.get('run_name')
    user = str(request.user)
    job_id = str(request.GET.get('job_id'))
    print_message(request.GET, 'ok')
    if not script_name:
        print_message('No script name given', 'error')
        return HttpResponse(status=400)

    if not run_name:
        print_message('No run config folder given', 'error')
        return HttpResponse(status=400)

    if not job_id:
        print_message('No job id given', 'error')
        return HttpResponse(status=400)

    try:
        run = UserRuns.objects.get(id=job_id)
    except Exception as e:
        print_debug(e)
        print_message('Error looking up job with id: {}'.format(job_id))
        return HttpResponse(status=500)

    contents = run.output
    return JsonResponse({'script': contents})
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:27,代码来源:views.py


示例3: test_copy_template_without_new_template

 def test_copy_template_without_new_template(self):
     request = {
         'new_template': 'ACME_script.csh'
     }
     r = self.c.post(self.url + 'copy_template/', data=json.dumps(request), content_type='application/json')
     print_message('status code given ' + str(r.status_code), 'error')
     self.assertTrue(r.status_code == 400)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:7,代码来源:tests.py


示例4: test_get_new_with_user

 def test_get_new_with_user(self):
     payload = {'request': 'new', 'user': 'acmetest'}
     r = self.c.get(self.live_server_url + '/poller/update/', data=payload, content_type='application/json')
     print_message('status code: {}'.format(r.status_code))
     self.assertTrue(r.status_code == 200)
     for record in json.loads(r.content):
         self.assertTrue(record['user'] == 'acmetest')
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:7,代码来源:tests.py


示例5: dispatch

def dispatch(message, data, user):
    destination = data.get('destination')
    if destination == 'dataset_download':
        return dataset_download(message, data, user)
    else:
        print_message('unrecognised destination {}'.format(destination))
        return -1
    return -1
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:8,代码来源:dispatcher.py


示例6: test_valid_run

 def test_valid_run(self):
     request = {
         'run_name': 'test_run',
         'run_type': 'diagnostic'
     }
     r = self.c.post(self.url, data=json.dumps(request), content_type='application/json')
     print_message('status code given' + str(r.status_code), 'error')
     self.assertTrue(r.status_code == 200)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:8,代码来源:tests.py


示例7: test_logon_success

 def test_logon_success(self):
     print "\n---->[+] Starting " + inspect.stack()[0][3]
     credential = {
         'username': self.username,
         'password': self.password
     }
     response_code = requests.get(self.live_server_url + '/esgf/logon/', params=credential).status_code
     message = 'Status code: {}'.format(response_code)
     print_message(message, 'error')
     self.assertTrue(response_code == 200)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:10,代码来源:tests.py


示例8: test_get_config_list

    def test_get_config_list(self):
        save_url = self.live_server_url + '/esgf/save_publish_config/'
        get_url = self.live_server_url + '/esgf/get_publish_config_list/'

        r = self.c.post(save_url, data=self.params, content_type='application/json')
        self.assertTrue(r.status_code == 200)
        r = self.c.post(get_url)
        print_message(r.content)
        self.assertTrue(r.status_code == 200)
        self.assertTrue('test_data' in json.loads(r.content))
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:10,代码来源:tests.py


示例9: test_get_new_run_status

 def test_get_new_run_status(self):
     # First create a valid run
     request = {
         'run_name': 'test_run',
         'run_type': 'diagnostic'
     }
     r = self.c.post(self.live_server_url + '/run_manager/create_run/', data=json.dumps(request), content_type='application/json')
     print_message("server url: {}".format(self.live_server_url))
     r = self.c.get(self.url)
     self.assertTrue(r.status_code == 200)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:10,代码来源:tests.py


示例10: get_publish_config_list

def get_publish_config_list(request):
    user = str(request.user)
    res = PublishConfig.objects.all().filter(user=user)
    if len(res) == 0:
        print_message('{} has no stored publication configs'.format(user))
        return HttpResponse()
    data = {}
    for r in res:
        data[ getattr(r, 'config_name') ] = getattr(r, 'facets')
    return HttpResponse(json.dumps(data))
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:10,代码来源:views.py


示例11: test_copy_template_with_invalid_old_template

 def test_copy_template_with_invalid_old_template(self):
     request = {
         'template': 'this_doesnt_exist',
         'new_template': 'invalid_copy_template'
     }
     r = self.c.post(self.url + 'copy_template/', data=json.dumps(request), content_type='application/json')
     print_message('status code given ' + str(r.status_code), 'error')
     self.assertTrue(r.status_code == 200)
     data = json.loads(r.content)
     self.assertTrue('error' in data and data['error'] == 'template not found')
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:10,代码来源:tests.py


示例12: test_get_runs_valid_user

    def test_get_runs_valid_user(self):
        request = json.dumps({
            'run_name': 'test_run',
            'run_type': 'diagnostic'
        })
        r = self.c.post(self.save_url, data=request, content_type='application/json')
        print_message('status code given {}'.format(str(r.status_code)), 'error')
        self.assertTrue(r.status_code == 200)

        r = self.c.get(self.get_url)
        print_message("request contents {}".format(r.content), 'error')
        self.assertTrue(r.status_code == 200)
        self.assertTrue('test_run' in r.content)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:13,代码来源:tests.py


示例13: test_copy_a_template

 def test_copy_a_template(self):
     request = {
         'template': 'ACME_script.csh',
         'new_template': 'copy_template'
     }
     r = self.c.post(self.url + 'copy_template/', data=json.dumps(request), content_type='application/json')
     print_message('status code given ' + str(r.status_code), 'error')
     self.assertTrue(r.status_code == 200)
     r = self.c.get(self.url + 'get_templates/', content_type='application/json')
     data = json.loads(r.content)
     print_message('templates found: ' + str(data), 'error')
     self.assertTrue('global/ACME_script.csh' in data)
     self.assertTrue('test/copy_template' in data)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:13,代码来源:tests.py


示例14: get_publish_config

def get_publish_config(request):
    user = str(request.user)
    config = request.GET.get('config_name')
    if not config:
        print_message('No config name given')
        return HttpResponse(status=403)
    res = PublishConfig.objects.get(config_name=config)
    data = {}
    for field in PublishConfig._meta.get_fields():
        item = str(field).split('.')[-1]
        print_message(item)
        data[item] = getattr(res, item)
    return HttpResponse(json.dumps(data))
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:13,代码来源:views.py


示例15: get_data_type_folders

def get_data_type_folders(request):
    user = str(request.user)
    try:
        data = json.loads(request.body)
    except Exception as e:
        print_message("Unable to load request body")
        print_debug(e)
        return HttpResponse(status=400)
    data_type = data.get('type')
    if not data_type:
        print_message('No data type given')
        return HttpResponse(status=400)

    folder_path = '{project_root}/userdata/{user}/'.format(
        project_root=project_root(),
        user=user)
    if data_type == 'diagnostic':
        folder_path += 'diagnostic_output'
    elif data_type == 'model':
        folder_path += 'model_output'
    elif data_type == 'observation':
        folder_path += 'observations'
    else:
        print_message('Invalid data_type {}'.format(data_type))
        return HttpResponse(status=400)

    print_message('Looking for folders in {}'.format(folder_path))
    folder_contents = os.listdir(folder_path)
    return HttpResponse(json.dumps(folder_contents))
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:29,代码来源:views.py


示例16: test_invalid_run_duplicate

    def test_invalid_run_duplicate(self):
        request = {
            'run_name': 'test_run',
            'run_type': 'diagnostic'
        }
        r = self.c.post(self.live_server_url + '/run_manager/create_run/', data=json.dumps(request), content_type='application/json')

        request = {
            'run_name': 'test_run',
            'run_type': 'diagnostic'
        }
        r = self.c.post(self.live_server_url + '/run_manager/create_run/', data=json.dumps(request), content_type='application/json')
        print_message('status code given ' + str(r.status_code), 'error')
        self.assertTrue(r.status_code == 409)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:14,代码来源:tests.py


示例17: send_data

def send_data(data):
    if not data:
        print_message('No jobs found', 'ok')
        return JsonResponse({}, status=200)
    obj_list = []
    for obj in data:
        config = json.loads(obj.config_options)
        obj_dict = {}
        obj_dict['job_id'] = obj.id
        obj_dict['user'] = obj.user
        obj_dict['status'] = obj.status
        obj_dict.update(config)
        obj_list.append(obj_dict)
    return JsonResponse(obj_list, safe=False)
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:14,代码来源:views.py


示例18: delete_run

def delete_run(request):
    data = json.loads(request.body)
    run_directory = data.get('run_name')
    user = str(request.user)
    if not run_directory:
        return HttpResponse(status=400)

    path = os.path.abspath(os.path.dirname(__file__))
    run_directory = path + RUN_SCRIPT_PATH + str(request.user) + '/' + run_directory

    if not os.path.exists(run_directory):
        print_message("Attempt to delete directory that doesnt exist {}".format(run_directory), 'error')
        return HttpResponse(status=401)

    if user != run_directory.split('/')[-2]:
        print_message("Attempt to delete someone elses run directory", 'error')
        return HttpResponse(status=403)

    try:
        shutil.rmtree(run_directory, ignore_errors=True)
    except Exception as e:
        print_message("Error removing run directory", 'error')
        return HttpResponse(status=500)

    if os.path.exists(run_directory):
        print_message("Failed to remove directory {}".format(run_directory), 'error')
        return HttpResponse(status=500)

    return HttpResponse()
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:29,代码来源:views.py


示例19: set_favorite_plot

def set_favorite_plot(request):
    user = str(request.user)
    data = json.loads(request.body)
    plot = data.get('plot')
    if not plot:
        print_message('no plot given')
        return HttpResponse(status=400)

    new_fav = FavoritePlot(user=user, plot=plot)
    try:
        new_fav.save()
    except Exception as e:
        print_debug(e)
        return HttpResponse(status=500)
    return HttpResponse()
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:15,代码来源:views.py


示例20: find_directory

 def find_directory(directory, model, obs):
     print_message('looking in {dir} for model: {model} and obs: {obs}'.format(
         dir=directory,
         model=model,
         obs=obs))
     model_path = None
     obs_path = None
     for dirname, subdirlist, filelist in os.walk(directory):
         for subdir in subdirlist:
             if subdir == model:
                 model_path = os.path.abspath(os.path.join(dirname, subdir))
             if subdir == obs:
                 obs_path = os.path.abspath(os.path.join(dirname, subdir))
             if model_path and obs_path:
                 return model_path, obs_path
     return '', ''
开发者ID:ACME-OUI,项目名称:acme-web-fe,代码行数:16,代码来源:views.py



注:本文中的util.utilities.print_message函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vocabulary.Vocabulary类代码示例发布时间:2022-05-26
下一篇:
Python utili18n.le2mtrans函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap