#If you're on Ubuntu or working with a Linux VM...
SSH into your server as a root or do sudo -i.
Then install necessary software:
apt-get update
# build opener | |
cj = cookielib.CookieJar() | |
cookieprocessor = urllib2.HTTPCookieProcessor(cj) | |
opener = urllib2.build_opener(cookieprocessor) | |
#opener.addheaders.append(('Cookie', 'id=%s' % USER.upper())) |
>>> resp = """Serial number:<br/> | |
... 353511021287981<br/> | |
... Warranty:<br/> | |
... NO <br/>""" | |
>>> import re | |
>>> patt = re.compile(r'([^>\r]+):.?<br/>.?([^<]+)', re.DOTALL) | |
>>> match = patt.search(resp) | |
>>> match | |
<_sre.SRE_Match object at 0x10535bb58> | |
>>> match.groups(0) |
<br/> | |
<br/> | |
<br/> | |
<br/> | |
<br/> | |
Extended Warranty Check<br/> | |
<br/> | |
<br/> | |
The following warranty information has been found:<br/> | |
<br/> |
@patch('urllib2.urlopen') | |
def test_api_handles_url_error(self, MockClass): | |
""" | |
usually raised where there's no connection to the host | |
system should inform enduser and admin | |
""" | |
import urllib2 | |
from imei.nokia.api import IrishGsmApi as Api | |
MockClass.return_value.side_effect = urllib2.URLError('The server couldn\'t fulfill the request.') |
class OauthTest(TestCase): | |
from gsmcenter.oauth.handlers.facebook import OauthHandler | |
@patch('gsmcenter.oauth.handlers.facebook.OauthHandler') | |
def test_handle_oauth_authentication_error(self, MockClass): | |
""" | |
test if user is being informed when facebook response returned error | |
""" | |
data = { | |
'code': 'AQD5H5TrUYUBveCzFECkQFDDBejeJeh4LqDSpQU4nQIY8-gmE3ggp7gVZ67zsvbSr1NoEgJK3UmiDDa_Zlih-yp580idyxYEVEkaFAu'\ |
#!/usr/bin/env python3.4 | |
import urllib.request | |
import asyncio | |
def return_response(url): | |
return urllib.request.urlopen(url).read() | |
@asyncio.coroutine | |
def read_page(loop, url): |
set nobackup | |
set nowritebackup | |
set noswapfile | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set autoindent | |
set smarttab | |
set expandtab | |
filetype indent on |
{ | |
"name": "my-app", | |
"version": "1.0.0", | |
"description": "My test app", | |
"main": "src/js/index.js", | |
"scripts": { | |
"jshint:dist": "jshint src/js/*.js'", | |
"jshint": "npm run jshint:dist", | |
"jscs": "jscs src/*.js", | |
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js", |