GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#1)
by
unknown
01:29
created

myawis.CallAwis   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 89
Duplicated Lines 0 %
Metric Value
dl 0
loc 89
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A CallAwis.traffichistory() 19 19 1
A CallAwis.__init__() 0 10 1
A CallAwis.create_uri() 0 4 2
A CallAwis.urlinfo() 20 20 1
A CallAwis.create_timestamp() 0 4 1
A CallAwis.cat_browse() 0 18 1
A CallAwis.create_signature() 0 6 1
1
import datetime
2
import urllib
3
import hmac
4
import hashlib
5
import base64
6
import requests
7
import sys
8
from bs4 import BeautifulSoup
9
from urllib import quote
10
11
class CallAwis(object):
12
	def __init__(self,domainname,responsegroup, access_id, secret_access_key):
13
		self.domainname=domainname
14
		self.responsegroup=responsegroup
15
		self.access_id = access_id
16
		self.secret_access_key = secret_access_key
17
		self.SignatureVersion = "2"
18
		self.SignatureMethod = "HmacSHA256"
19
		self.ServiceHost = "awis.amazonaws.com"
20
		self.range="31"
21
		self.PATH = "/"
22
23
	def create_timestamp(self):
24
	    now = datetime.datetime.now()
25
	    timestamp = now.isoformat()
26
	    return timestamp
27
28
	def create_uri(self,params):
29
	    params = [(key, params[key])
30
	        for key in sorted(params.keys())]
31
	    return urllib.urlencode(params)
32
33
	def create_signature(self):
34
	    Uri = self.create_uri(self.params)
35
	    msg = "\n".join(["GET", self.ServiceHost, self.PATH, Uri])
36
	    hmac_signature = hmac.new(self.secret_access_key, msg, hashlib.sha256)
37
	    signature = base64.b64encode(hmac_signature.digest())
38
	    return urllib.quote(signature)
39
40 View Code Duplication
	def urlinfo(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
41
		#Query Options  # refer to AWIS API reference for full details.
42
		Action = "UrlInfo"
43
		self.params = {
44
	    'Action':Action,
45
	    'Url':self.domainname,
46
	    'ResponseGroup':self.responsegroup,
47
	    'SignatureVersion':self.SignatureVersion,
48
	    'SignatureMethod':self.SignatureMethod,
49
	    'Timestamp': self.create_timestamp(),
50
	    'AWSAccessKeyId':self.access_id,
51
	    }
52
53
		uri = self.create_uri(self.params)
54
		signature = self.create_signature()
55
56
		url = "http://%s/?%s&Signature=%s" % (self.ServiceHost, uri, signature)
57
		r=requests.get(url)
58
		soup=BeautifulSoup(r.text.encode('utf-8'),'xml')
59
		return soup
60
61 View Code Duplication
	def traffichistory(self,myrange='31',start='20070801'):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
62
		Action="TrafficHistory"
63
		self.params={
64
		'Action':Action,
65
		'AWSAccessKeyId':self.access_id,
66
		'SignatureMethod':self.SignatureMethod,
67
		'SignatureVersion':self.SignatureVersion,
68
		'Timestamp':self.create_timestamp(),
69
		'Url':self.domainname,
70
		'ResponseGroup':self.responsegroup,
71
		'Range':myrange,
72
		'Start':start,
73
		}
74
		uri = self.create_uri(self.params)
75
		signature = self.create_signature()
76
		url = "http://%s/?%s&Signature=%s" % (self.ServiceHost, uri, signature)
77
		r=requests.get(url)
78
		soup=BeautifulSoup(r.text.encode('utf-8'),'xml')
79
		return soup
80
81
82
	def cat_browse(self,path):
83
		Action='CategoryListings'
84
		self.params={
85
		'Action':Action,
86
		'AWSAccessKeyId':self.access_id,
87
		'SignatureMethod':self.SignatureMethod,
88
		'SignatureVersion':self.SignatureVersion,
89
		'Timestamp':self.create_timestamp(),
90
		'ResponseGroup':'Listings',
91
		'Path':quote(path),
92
		}
93
		uri = self.create_uri(self.params)
94
		signature = self.create_signature()
95
		url = "http://%s/?%s&Signature=%s" % (self.ServiceHost, uri, signature)
96
		# print url
97
		r=requests.get(url)
98
		soup=BeautifulSoup(r.text.encode('utf-8'),'xml')
99
		return soup
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114