예제 #1
0
파일: data.py 프로젝트: OspreyX/flow
import platform

from djpcms.core.exceptions import ObjectDoesNotExist
from djpcms.conf import settings
from djpcms.utils.ajax import jhtmls
from djpcms.views import appsite, appview
from djpcms.views.apps.tagging import TagApplication

from dynts.web.views import TimeSeriesView as TimeSeriesViewBase

import unuk
from unuk.http import httplib
from unuk.core.jsonrpc import Proxy

unuk.importlib('servermachine')
from servermachine.forms import ServerForm, ServerMachine

from jflow.db.instdata.models import DataId, EconometricAnalysis, VendorId
from jflow.web import forms


class TimeSeriesView(TimeSeriesViewBase):
    
    def getdata(self, request, code, start, end):
        try:
            p = self.appmodel.proxy()
            return p.raw_parsets(code = code, start = start, end = end)
        except Exception, e:
            return str(e)
    
    def codeobject(self, object):
예제 #2
0
import platform

from djpcms.core.exceptions import ObjectDoesNotExist
from djpcms.conf import settings
from djpcms.utils.ajax import jhtmls
from djpcms.views import appsite, appview
from djpcms.views.apps.tagging import TagApplication

from dynts.web.views import TimeSeriesView as TimeSeriesViewBase

import unuk
from unuk.http import httplib
from unuk.core.jsonrpc import Proxy

unuk.importlib('servermachine')
from servermachine.forms import ServerForm, ServerMachine

from jflow.db.instdata.models import DataId, EconometricAnalysis, VendorId
from jflow.web import forms


class TimeSeriesView(TimeSeriesViewBase):
    def getdata(self, request, code, start, end):
        try:
            p = self.appmodel.proxy()
            return p.raw_parsets(code=code, start=start, end=end)
        except Exception, e:
            return str(e)

    def codeobject(self, object):
        return object.code
예제 #3
0
#Import 4 different classes for opening urls:
# * httplib0 - standard urllib library for python 2.* - Deprecated, only used for testing
# * httplib1 - urllib2 in python 2 / urllib in python 3 
# * httplib2 - http://code.google.com/p/httplib2/
# * httplib3 - use pycurl
# * httplib4 - pycurl and httplib together
#
import urllib
from urlparse import urlparse

import unuk
socks = unuk.importlib('socks')
from ._urllib import httplib1
from httplib2 import ProxyInfo, Response
from httplib2 import Http as httplib2

LIB_SUFFIXES = (1,2,3,4)

def getproxy(schema = 'http'):
    p = urllib.getproxies_environment()
    return p.get(schema,None)


class httplib0(urllib.URLopener):
    
    def request(self, url, method='GET', **kwargs):
        if method == 'GET':
            c  = self.open(url)
            content = c.read()
            response = Response({'status':c.code,
                                 'headers':c.headers,