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

Python posixpath.urljoin函数代码示例

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

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



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

示例1: __init__

    def __init__(self, investor_id, api_key, api_version='v1', 
                 host='api.lendingclub.com', path='/api/investor'):
        """Connection to LendingClub API.  
        
        Each client requires an `investor_id` and `api_key`.  All other 
        arguments are optional.

        Args:
          investor_id (int): The accounts Investor Id this can be found on the 
            Account Summary page on the LendingClub website after loging in.
          api_key (str): Account authorization token found under Settings.
          api_version (str, optional): api version endpoint.
          host (str, optional): Host name of api endpoint.
          path (str, optional): Base path of api endpoint.
        
        """
        self._last_update = None
        self._host = host
        investor_id = str(investor_id)
        self._investor_id = investor_id
        self._base_path = urljoin(path, api_version)
        self._acct_path = urljoin(self._base_path, 'accounts', investor_id) 
        self._loan_path = urljoin(self._base_path, 'loans')

        self._default_headers = {'Authorization': api_key,
                                 'Accept': 'application/json',
                                 'Content-type': 'application/json'}

        ssl_ctx = create_default_context(Purpose.SERVER_AUTH)
        self._conn = HTTPSConnection(host, context=ssl_ctx)
        self._conn.set_debuglevel(10)

        self._conn.connect()
开发者ID:pmorici,项目名称:loanshark,代码行数:33,代码来源:__init__.py


示例2: main

def main():
    # 获取参数
    xArg = sys.argv[1:]

    # 参数个数目前为4个
    args_nums = len(xArg)
    if args_nums != 4:
        print 'input args num error'
        return

    # 获取处理文件时间和文件类型
    Ftime = xArg[0]
    Ftype1 = xArg[1]
    Ftype2 = xArg[2]
    Frate = xArg[3]

    # 解析配置文件
    group = '%s-%s' % (Ftype1, Ftype2)
    I_DIR = Cfg[group]['I_DIR']
    O_DIR = Cfg[group]['O_DIR']

    date_s, date_e = ymd2date(Ftime)
    I_FILE = urljoin(I_DIR, group + '_' + Frate + '.txt')
    O_FILE = urljoin(I_DIR, group + '_' + Frate)
    DATA = ReadFile(I_FILE, date_s, date_e)
    print DATA

    DictTitle = {'xlabel': 'Site CO2', 'ylabel': 'Sate CO2', 'title': '%s-%s' % (Ftype1, Ftype2)}
    ds_PUB_LIB.draw_Scatter(DATA['SiteCo2'], DATA['SateCo2'], O_FILE, DictTitle, '', '')
开发者ID:Ariel-King,项目名称:tansat,代码行数:29,代码来源:ds_regression.py


示例3: __init__

 def __init__(self, host="http://127.0.0.1:7796/", key=None, verify=False):
     self.host = host
     self.api = urljoin(host, 'preql/q')
     self.update = urljoin(host, 'preql/update')
     self.error_params = ["SynthDB.connect('{}')".format(self.host), "No instance of SynthDB found at {}".format(self.host), self.host]
     self.key = key
     self.verify = verify
     self.delim = '\t'
开发者ID:shawnrushefsky,项目名称:SynthDB,代码行数:8,代码来源:synthdb.py


示例4: main

def main():
    # 获取参数
    xArg = sys.argv[1:]

    # 参数个数目前为3个
    args_nums = len(xArg)
    if args_nums != 2:
        print ' args nums error'
        return

    # 获取处理文件时间和文件类型
    Ftime = xArg[0]
    Ftype = xArg[1]

    # 解析配置文件
    I_DIR = Cfg[Ftype]['I_DIR']
    O_DIR = Cfg[Ftype]['O_DIR']

    SiteList = urljoin(O_DIR, Ftype, 'SiteList.txt')

    if os.path.exists(SiteList):
        fp = open(SiteList, 'r')
        SiteList = fp.readlines()
        fp.close()
    else:
        print u'站点列表文件不存在'
        return

    for siteLine in SiteList:
        if siteLine.strip() == '':
            continue
        siteName = siteLine.strip().split()[0]
        start_time = siteLine.strip().split()[3].replace('-', '')
        end_time = siteLine.strip().split()[4].replace('-','')
        Ftime = start_time + '-' + end_time
        print siteName, start_time, end_time
        date_s, date_e = ymd2date(Ftime)

        while date_s <= date_e:
            ymd = date_s.strftime('%Y%m%d')
            FULL_I_DIR =  urljoin(I_DIR, Ftype, siteName)
            # 输出文件在站点名下,按日输出,每天一个文件
            O_FILE = urljoin(O_DIR, Ftype, siteName, ymd[:4], ymd + '.txt')

            # 实例化WDCGG类
            tccon = TCCON()
            # 对类的全局变量赋值
            tccon.YMD = date_s
            tccon.SiteName = siteName
            # 开始处理
            tccon.FindFile(FULL_I_DIR)
            tccon.ReadFile()
            tccon.Filter()
            print  ymd,len(tccon.FileLine), len(tccon.FileData)
            tccon.Write(O_FILE)
            date_s = date_s + relativedelta(days=1)
开发者ID:Ariel-King,项目名称:tansat,代码行数:56,代码来源:dp_extract_tccon_day.py


示例5: main

def main():
    # 获取参数
    xArg = sys.argv[1:]

    # 参数个数目前为2个
    args_nums = len(xArg)
    if args_nums != 2:
        print ' args nums error'
        return

    # 获取处理文件时间和文件类型
    Ftime = xArg[0]
    Ftype = xArg[1]

    # 解析配置文件
    I_DIR = Cfg[Ftype]['I_DIR']
    O_DIR = Cfg[Ftype]['O_DIR']

    SiteList = urljoin(O_DIR, Ftype, 'SiteList.txt')

    if os.path.exists(SiteList):
        fp = open(SiteList, 'r')
        SiteList = fp.readlines()
        fp.close()
    else:
        print u'站点列表文件不存在'
        return

    for siteLine in SiteList:
        if siteLine.strip() == '':
            continue
        date_s, date_e = ymd2date(Ftime)
        siteName = siteLine.strip().split()[0]
        print siteName
        while date_s <= date_e:
            ymd = date_s.strftime('%Y%m%d')
            FULL_I_DIR = urljoin(I_DIR, Ftype, siteName)
            O_FILE = urljoin(O_DIR, Ftype, siteName, ymd[:4], ymd + '.txt')

            # 实例化GGA类
            gga = GGA()
            # 类中的全局变量赋值
            gga.YMD = date_s
            gga.SiteName = siteName

            # 开始提取文件
            gga.FindFile(FULL_I_DIR)
            gga.ReadFile()
            gga.Filter()
            gga.Write(O_FILE)
            print ymd, len(gga.FileData)
            date_s = date_s + relativedelta(days=1)
开发者ID:Ariel-King,项目名称:tansat,代码行数:52,代码来源:dp_extract_gga.py


示例6: show_hours

def show_hours(date_s, Ftype):
    IDIR = Cfg[Ftype]['I_DIR']
    ODIR = Cfg[Ftype]['O_DIR_H']
    AERA = Cfg[Ftype]['L2S']

    TimeList = []
    DictData = {}
    for i in range(24):
        dateT1 = date_s + relativedelta(hours=i)
        TimeList.append(dateT1)

    for aera in AERA.keys():
        Line = []
        shortname = Cfg[Ftype]['L2S'][aera].decode('utf-8')
        ymd = date_s.strftime('%Y%m%d')
        FileName = urljoin(IDIR, aera, 'hours', ymd + '.txt')
        print FileName
        if os.path.isfile(FileName) and os.path.getsize(FileName) != 0:
            ary = np.loadtxt(FileName, dtype=dtype, skiprows=1).reshape((-1,))
        else:
            for i in range(24):
                t_str = '%s %s %f %f %f %d' % (ymd, '00:00:00', np.nan, np.nan, np.nan, 9999)
                Line.append([each.strip() for each in t_str.split()])
            ary = np.core.records.fromarrays(np.array(Line).transpose(),
                names=','.join(dname_Nan),
                formats=','.join(dtype_Nan))
        DictData[shortname] = ary
    # print DictData

    if not os.path.isdir(ODIR):
        os.makedirs(ODIR)
    # 平均值
    DictMean = {}
    color_dict = {}
    for eachkey in DictData.keys():
        DictMean[eachkey] = DictData[eachkey]['mean']
        print 'TimeList', len(TimeList), eachkey, len(DictMean[eachkey])

    DictVar = {}
    for eachkey in DictData.keys():
        DictVar[eachkey] = DictData[eachkey]['var']
        print 'TimeList', len(TimeList), eachkey, len(DictVar[eachkey])

    DictTitle1 = {'xlabel': 'x %s' % ymd, 'ylabel': 'mean', 'title': 'gga'}
    DictTitle2 = {'xlabel': 'x %s' % ymd, 'ylabel': 'Var', 'title': 'gga'}
    # ymd = time.strftime('%Y%m%d', time.localtime())

    Outimg1 = urljoin(ODIR, ymd + '_mean')
    Outimg2 = urljoin(ODIR, ymd + '_var')

    ds_PUB_LIB.draw_time_fig(TimeList, DictMean, Outimg1, DictTitle1, 'H')
    ds_PUB_LIB.draw_time_fig(TimeList, DictVar, Outimg2, DictTitle2, 'H')
开发者ID:Ariel-King,项目名称:tansat,代码行数:52,代码来源:ds_time_sequence.py


示例7: show_day

def show_day(Ftype, Ftime):
    IDIR = Cfg[Ftype]['I_DIR']
    ODIR = Cfg[Ftype]['O_DIR_D']
    AERA = Cfg[Ftype]['L2S']

    TimeList = []
    DictData = {}
    date_s, date_e = ymd2date(Ftime)
    while date_s <= date_e:
        TimeList.append(date_s)
        date_s = date_s + relativedelta(days=1)
    for aera in AERA.keys():
        shortname = Cfg[Ftype]['L2S'][aera].decode('utf-8')
        print shortname
        FileList = []
        date_s, date_e = ymd2date(Ftime)
        while date_s <= date_e:
            ymd = date_s.strftime('%Y%m%d')
            FileName = urljoin(IDIR, aera, 'days', ymd + '.txt')
            FileList.append(FileName)
            date_s = date_s + relativedelta(days=1)
        data = combine_day(FileList)
        DictData[shortname] = data

    if not os.path.isdir(ODIR):
        os.makedirs(ODIR)
    print DictData
    # 平均值
    DictMean = {}
    for eachkey in DictData.keys():
        DictMean[eachkey] = DictData[eachkey]['mean']
        print 'TimeList', len(TimeList), eachkey, len(DictMean[eachkey])

        print len(TimeList), len(DictData[eachkey])

    # 偏差
    DictVar = {}
    for eachkey in DictData.keys():
        DictVar[eachkey] = DictData[eachkey]['var']
        print 'TimeList', len(TimeList), eachkey, len(DictVar[eachkey])

    DictTitle1 = {'xlabel': 'x %s' % ymd, 'ylabel': 'mean', 'title': 'gga'}
    DictTitle2 = {'xlabel': 'x %s' % ymd, 'ylabel': 'Var', 'title': 'gga'}
    # ymd = time.strftime('%Y%m%d', time.localtime())

    Outimg1 = urljoin(ODIR, ymd + '_mean')
    Outimg2 = urljoin(ODIR, ymd + '_var')

    ds_PUB_LIB.draw_time_fig(TimeList, DictMean, Outimg1, DictTitle1, 'D')
    ds_PUB_LIB.draw_time_fig(TimeList, DictVar, Outimg2, DictTitle2, 'D')
开发者ID:Ariel-King,项目名称:tansat,代码行数:50,代码来源:ds_time_sequence.py


示例8: retrive_save_document

    def retrive_save_document(self, analysis_id):
        combo_resource_url = urljoin(BACKEND_HOST, "api/v1/analysiscombo/{}/?format=json".format(analysis_id))
        retrive_headers = {'Authorization': 'ApiKey {}:{}'.format(API_USER,API_KEY)}
        logger.debug("Fetching resource from {}".format(combo_resource_url))

        r = False
        while not r:
            try:
                r = requests.get(combo_resource_url, headers = retrive_headers)
            except requests.exceptions.ConnectionError:
                logger.debug("Got a requests.exceptions.ConnectionError exception, will try again in {} seconds".format(SLEEP_TIME_ERROR))
                time.sleep(SLEEP_TIME_ERROR)
        response = r.json()
        logger.debug(response)
        #now files for locations
        for x in response["locations"]:
            if x['content_id'] != None:
                download_url = urljoin(BACKEND_HOST, "api/v1/location/", x['content_id'], "file/")
                new_fs_id = self.fetch_save_file(download_url)
                #now change id in repsonse
                x['location_id'] = new_fs_id
        # now for samples
        for x in response["samples"]:
            download_url = urljoin(BACKEND_HOST, "api/v1/sample/", x['sample_id'], "file/")
            new_fs_id = self.fetch_save_file(download_url)
            #now change id in repsonse
            x['sample_id'] = new_fs_id
        # same for pcaps
        for x in response["pcaps"]:
            if x['content_id'] is None:
                continue
            download_url = urljoin(BACKEND_HOST, "api/v1/pcap/", x['content_id'], "file/")
            new_fs_id = self.fetch_save_file(download_url)
            #now change id in repsonse
            x['content_id'] = new_fs_id
        #for vt,andro etc. eoint sample_id to gridfs id
        # check for issues in this
        for x in response["virustotal"]:
            x['sample_id'] = search_samples_dict_list(x['sample_id'],response["samples"])
        for x in response["honeyagent"]:
            x['sample_id'] = search_samples_dict_list(x['sample_id'],response["samples"])
        for x in response["androguard"]:
            x['sample_id'] = search_samples_dict_list(x['sample_id'],response["samples"])
        for x in response["peepdf"]:
            x['sample_id'] = search_samples_dict_list(x['sample_id'],response["samples"])
        #remove id from all samples and pcaps
        for x in response["samples"]:
            x.pop("_id")
        frontend_analysis_id = db.analysiscombo.insert(response)
        return frontend_analysis_id
开发者ID:satwik77,项目名称:rumal,代码行数:50,代码来源:fdaemon.py


示例9: main

def main():
    # 获取参数
    xArg = sys.argv[1:]

    # 参数个数目前为1个
    args_nums = len(xArg)
    if args_nums != 1:
        print ' args nums error'
        return

    # 获取处理文件时间和文件类型
    Ftype = xArg[0]

    # 解析配置文件
    I_DIR = Cfg[Ftype]['I_DIR']
    O_DIR = Cfg[Ftype]['O_DIR']

    SiteList = urljoin(O_DIR, Ftype, 'SiteList.txt')

    if os.path.exists(SiteList):
        fp = open(SiteList, 'r')
        SiteList = fp.readlines()
        fp.close()
    else:
        print u'站点列表文件不存在'
        return

    for siteLine in SiteList:
        if siteLine.strip() == '':
            continue
        siteName = siteLine.strip().split()[0]
        # 根据站点开始 结束时间 来处理数据,手动时可注释掉
        start_time = siteLine.strip().split()[3].replace('-', '')
        end_time = siteLine.strip().split()[4].replace('-','')
        Ftime = start_time + '-' + end_time

        print siteName, start_time, end_time
        date_s, date_e = ymd2date(Ftime)
        siteName = siteLine.strip().split()[0]
        FULL_I_DIR = urljoin(I_DIR, Ftype, siteName)
        oFile = urljoin(O_DIR, Ftype, siteName, 'time_series.txt')

        tccon = TCCON()
        tccon.FindFile(FULL_I_DIR)
        tccon.ReadFile()
        tccon.Combine_S(date_s, date_e)
        tccon.Write_S(oFile)
        print oFile
开发者ID:Ariel-King,项目名称:tansat,代码行数:48,代码来源:dp_extract_tccon.py


示例10: request

def request(session, base_path, method, path, **kwargs):
    """Construct a :class:`requests.Request` object and send it.

    :param requests.Session session:
    :param str base_path:
    :param str method: Method for the :class:`requests.Request` object.
    :param str path: (optional) The path to join with :attr:`CouchDB.url`.
    :param kwargs: (optional) Arguments that :meth:`requests.Session.request` takes.
    :rtype: requests.Response
    """
    # Prepare the params dictionary
    if ('params' in kwargs) and isinstance(kwargs['params'], dict):
        params = kwargs['params'].copy()
        for key, val in iteritems(params):
            # Handle titlecase booleans
            if isinstance(val, bool):
                params[key] = json.dumps(val)
        kwargs['params'] = params

    if compat.urlparse(path).scheme:
        # Support absolute URLs
        url = path
    else:
        url = urljoin(base_path, path).strip('/')

    r = session.request(method, url, **kwargs)
    # Raise exception on a bad status code
    if not (200 <= r.status_code < 300):
        utils.raise_http_exception(r)

    return r
开发者ID:rwanyoike,项目名称:time2relax,代码行数:31,代码来源:time2relax.py


示例11: insert_att

def insert_att(doc_id, doc_rev, att_id, att, att_type, **kwargs):
    """Create or update an existing attachment.

    http://docs.couchdb.org/en/stable/api/document/attachments.html#put--db-docid-attname

    :param str doc_id: The attachment document.
    :param doc_rev: (optional) The document revision.
    :param str att_id: The attachment name.
    :param att: The dictionary, bytes, or file-like object to insert.
    :param str att_type: The attachment MIME type.
    :param kwargs: (optional) Arguments that :meth:`requests.Session.request` takes.
    :rtype: (str, str, dict)
    """
    if doc_rev:
        if ('params' not in kwargs) or (not isinstance(kwargs['params'], dict)):
            kwargs['params'] = {}
        kwargs['params']['rev'] = doc_rev

    if ('headers' not in kwargs) or (not isinstance(kwargs['headers'], dict)):
        kwargs['headers'] = {}

    path = urljoin(utils.encode_document_id(doc_id), utils.encode_attachment_id(att_id))
    kwargs['headers']['Content-Type'] = att_type
    kwargs['data'] = att

    return 'PUT', path, kwargs
开发者ID:rwanyoike,项目名称:time2relax,代码行数:26,代码来源:time2relax.py


示例12: actions

    def actions(self, appfolder, controller, skipped, skip_auth=False):
        """
        Generator.
        Parse codelines from controller code and yield '<controller>/<action>' strings.

        Args:
            appfolder: application folder
            controller: name of the controller (without .py) ['<controller>/*' will be converted into 'controller']
            skipped: list of actions we want to skip/ignore them
            skip_auth: if True, all @auth. decorated actions will be skipped too (useful for unlogged user)
        """
        controller = controller.split('/')[0]  # <controller> or <controller/*> can be used
        codelines = self.get_controller_codelines(appfolder, controller)
        skip_next = False
        for ln in codelines:
            ln = ln.rstrip()  # - \n

            if ln[:4] == 'def ':  # function without parameters, maybe Web2py action
                if not skip_next and ln[-3:] == '():':
                    action = ln[4:-3].strip()
                    if action[:2] != '__':                 # Web2py action
                        url = urljoin(controller, action)
                        if url not in skipped:
                            yield url
                skip_next = False
            elif skip_auth and ln[:6] == '@auth.' or re.match('^#\s*ajax$', ln):   #  unlogged user + need authorize --or-- # ajax
                skip_next = True
开发者ID:zvolsky,项目名称:codex2020,代码行数:27,代码来源:plugin_splinter.py


示例13: controllers

 def controllers(appfolder):
     """
         yields names of all controllers (without .py) except off appadmin
     """
     for controller in os.listdir(urljoin(appfolder, 'controllers')):
         if controller[-3:] == '.py' and not controller == 'appadmin.py':
             yield controller[:-3]
开发者ID:zvolsky,项目名称:codex2020,代码行数:7,代码来源:plugin_splinter.py


示例14: set_piazza

def set_piazza(course_id, piazza_id):
    """Uses the backend API to add a course to the course list"""
    course_id = str(course_id)
    ret = post(urljoin(URL, course_id, 'course/setpiazza/'), data={'piazza_cid': piazza_id})
    if ret.status_code != 200:
        raise ValueError('Unable to add piazza id %s' % piazza_id)
    return ret
开发者ID:nfischer,项目名称:course-dashboard,代码行数:7,代码来源:addSampleData.py


示例15: set_temporary_password

    def set_temporary_password(self, client_id, client_secret, username, new_password):
        """ Changes password on behalf of the user with client credentials

        Args:
            client_id: The oauth client id that this code was generated for
            client_secret: The secret for the client_id above
            user_id: the user id to act on
            new_password: the users desired password

        Raises:
            UAAError: there was an error changing the password

        Returns:
            boolean: Success/failure
        """
        list_filter = 'userName eq "{0}"'.format(username)
        userList = self.client_users(client_id, client_secret, list_filter=list_filter)

        if len(userList['resources']) > 0:
            user_id = userList['resources'][0]['id']
            token = self._get_client_token(client_id, client_secret)
            self._request(
                urljoin('/Users', user_id, 'password'),
                'PUT',
                body={
                    'password': new_password
                },
                headers={
                    'Authorization': 'Bearer ' + token
                }
            )
            return True

        return False
开发者ID:18F,项目名称:cg-uaa-invite,代码行数:34,代码来源:uaa.py


示例16: FindFile

    def FindFile(self, dir):

        # 拼接数据上的日期格式,当天
        StrYmd1 = self.YMD.strftime('%d%b%Y')
        # 拼接数据上的日期格式,昨天
        yesterday = self.YMD - relativedelta(days=1)
        StrYmd2 = yesterday.strftime('%d%b%Y')
        # 要查找当天文件的正则
        patFile1 = '\Agga_%s_f000(\d{1}).txt\Z' % StrYmd1
        patFile2 = '\Agga_%s_f000(\d{1}).txt\Z' % StrYmd2
        # 对目录进行递归查找,找出符合规则的所有文件
        Lst = sorted(os.listdir(dir), reverse=True)
        for Line in Lst:
            FullPath = urljoin(dir, Line)
            # 如果是目录则进行递归
            if os.path.isdir(FullPath):
                self.FindFile(FullPath)
            # 如果是文件则进行正则判断,并把符合规则的所有文件保存到List中
            elif os.path.isfile(FullPath):
                FileName = os.path.split(FullPath)[1]
                R1 = re.match(patFile1, FileName)
                R2 = re.match(patFile2, FileName)
                if R1:
                    self.FileList.append(FullPath)
                if R2:
                    self.FileList.append(FullPath)
开发者ID:Ariel-King,项目名称:tansat,代码行数:26,代码来源:dp_extract_gga.py


示例17: request

def request(name, cookies=USE_DEFAULT, game_number=USE_DEFAULT, json=True, extra_opts={}, **data):
	"""Do a request with given name and form data."""

	if cookies == USE_DEFAULT:
		global default_cookies
		if not default_cookies:
			with open(os.path.expanduser(DEFAULT_COOKIE_PATH)) as f:
				default_cookies = parse_cookies(f.read().strip())
		cookies = default_cookies
	elif isinstance(cookies, basestring):
		cookies = parse_cookies(cookies)

	if game_number == USE_DEFAULT:
		game_number = os.environ['NP_GAME_NUMBER']

	url = urljoin(BASE_URL, name)
	data['type'] = name
	if game_number: data['game_number'] = game_number

	resp = requests.post(url, data=data, cookies=cookies, **extra_opts)
	resp.raise_for_status()
	if not json: return resp.text
	resp_obj = decode_json(resp.text)
	report = resp_obj.get('report', None)

	if report == 'must_be_logged_in':
		raise RequestError(report)

	return report
开发者ID:Krusty-Media,项目名称:neptunesfolly,代码行数:29,代码来源:request.py


示例18: __init__

    def __init__(self, url, create_db=True):
        """Initialize the database object.

        :param str url: The Database URL.
        :param bool create_db: (optional) Create the database.
        """
        # Raise exception on an invalid URL
        Request('HEAD', url).prepare()

        #: Database host
        self.host = utils.get_database_host(url)

        #: Database name
        self.name = utils.get_database_name(url)

        #: Database URL
        # FIXME: Converts "https://test.db/a/b/index.html?e=f" to "https://test.db/index.html"
        self.url = urljoin(self.host, self.name)

        #: Database initialization
        self.create_db = create_db

        #: Default :class:`requests.Session`
        self.session = Session()
        # http://docs.couchdb.org/en/stable/api/basics.html#request-headers
        self.session.headers['Accept'] = 'application/json'
开发者ID:rwanyoike,项目名称:time2relax,代码行数:26,代码来源:models.py


示例19: main

def main():
    # 获取参数
    xArg = sys.argv[1:]

    # 参数个数目前为1个
    args_nums = len(xArg)
    if args_nums != 1:
        print ' args nums error'
        return

    # 获取处理文件时间和文件类型
    Ftype = xArg[0]

    # 解析配置文件
    I_DIR = Cfg[Ftype]['I_DIR']
    O_DIR = Cfg[Ftype]['O_DIR']

    # 一维LIST去重方法
    # l1 = ['b','c','d','b','c','a']
    # l2 = {}.fromkeys(l1).keys()

    SiteList = urljoin(O_DIR, Ftype,  'SiteList.txt')
    if os.path.exists(SiteList):
        fp = open(SiteList, 'r')
        SiteList = fp.readlines()
        fp.close()
    else:
        print u'站点列表文件不存在'
        return

    for siteLine in SiteList:
        if siteLine.strip() == '':
            continue
        siteName =  siteLine.strip().split()[0]
        # 根据站点开始 结束时间 来处理数据,手动时可注释掉
        start_time = siteLine.strip().split()[3].replace('-', '')
        end_time = siteLine.strip().split()[4].replace('-','')
        Ftime = start_time + '-' + end_time
        print siteName, start_time, end_time
        date_s, date_e = ymd2date(Ftime)
        wdcgg = WDCGG()
        wdcgg.SiteName = siteName
        oFile = urljoin(O_DIR, Ftype, wdcgg.SiteName, 'time_series.txt')
        wdcgg.FindFile(I_DIR)
        wdcgg.ReadFile()
        wdcgg.Combine_S(date_s, date_e)
        wdcgg.Write_S(oFile)
开发者ID:Ariel-King,项目名称:tansat,代码行数:47,代码来源:dp_extract_wdcgg.py


示例20: create_node

def create_node(course_id, contents='foo', renderer='bar'):
    """Uses the backend API to create a node"""
    node_value = {'contents': contents, 'renderer': renderer}
    course_id = str(course_id)
    ret = post(urljoin(URL, course_id, 'node/add/'), data=node_value)
    if ret.status_code != 200:
        raise ValueError('Unable to create node')
    return ret
开发者ID:nfischer,项目名称:course-dashboard,代码行数:8,代码来源:addSampleData.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python views.get_user函数代码示例发布时间:2022-05-25
下一篇:
Python posixpath.ujoin函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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