├── API_REQUESTS
├── requirements.txt
├── README.md
├── __init__.py
├── login.py
├── fuel_locks.py
├── add_credit.py
├── api
│ ├── giftcard.py
│ ├── __init__.py
│ ├── creditcard.py
│ ├── account.py
│ └── fuellock.py
└── muti_lock_in.py
├── favicon.ico
├── .gitignore
├── static
├── fonts
│ └── PoiretOne-Regular.ttf
├── images
│ └── 7-eleven_logo.svg
└── css
│ └── style.css
├── android_req.txt
├── requirements.txt
├── autolock.ini
├── Dockerfile
├── __init__.py
├── templates
├── confirm_price.html
├── index.html
└── price.html
├── settings.py
├── README.md
├── functions.py
├── autolocker.py
├── app.py
└── LICENSE
/API_REQUESTS/requirements.txt:
--------------------------------------------------------------------------------
1 | requests==2.20.0
2 |
--------------------------------------------------------------------------------
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freyta/7Eleven-Python/HEAD/favicon.ico
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.pyo
3 | *.json
4 | /__pycache__/*
5 | settings.py
6 | settings.py
7 | autolock.ini
8 |
--------------------------------------------------------------------------------
/static/fonts/PoiretOne-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/freyta/7Eleven-Python/HEAD/static/fonts/PoiretOne-Regular.ttf
--------------------------------------------------------------------------------
/android_req.txt:
--------------------------------------------------------------------------------
1 | googlemaps==3.0.2
2 | requests==2.20.0
3 | Flask==1.0.2
4 | pytz
5 | configparser
6 | apscheduler
7 | beautifulsoup4
8 | pydes
9 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | googlemaps==3.0.2
2 | requests==2.20.0
3 | Flask==1.0.2
4 | pytz
5 | configparser
6 | apscheduler
7 | beautifulsoup4
8 | pyOpenSSL==18.0.0
9 | flask_basicauth
10 | pydes
11 |
--------------------------------------------------------------------------------
/autolock.ini:
--------------------------------------------------------------------------------
1 | [General]
2 | auto_lock_enabled = True
3 | max_price = 138.0
4 |
5 | [Account]
6 | devicesecret =
7 | accesstoken =
8 | cardbalance =
9 | device_id =
10 | account_id =
11 | fuel_lock_saved = False
12 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3.7-alpine
2 |
3 | RUN apk --update add --no-cache bash tzdata build-base libffi-dev openssl-dev
4 |
5 | WORKDIR .
6 |
7 | COPY requirements.txt ./
8 | RUN pip install --no-cache-dir -r requirements.txt
9 |
10 | COPY . .
11 |
12 | ENTRYPOINT [ "python", "app.py" ]
13 |
--------------------------------------------------------------------------------
/API_REQUESTS/README.md:
--------------------------------------------------------------------------------
1 | # 7-Eleven Python API
2 | This is most of the API commands that are used throughout the 7-Eleven Fuel app. I have included some examples of how to do a few things to show you how simple it really is.
3 |
4 | # Setup
5 | You will need to install the dependencies in requirements.txt, you can use pip as follows `pip install -r requirements.txt`
6 |
--------------------------------------------------------------------------------
/API_REQUESTS/__init__.py:
--------------------------------------------------------------------------------
1 | '''
2 | 7-Eleven Python implementation.
3 |
4 | Copyright (C) 2019 Freyta
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 | You should have received a copy of the GNU General Public License
14 | along with this program. If not, see .
15 | '''
16 |
--------------------------------------------------------------------------------
/__init__.py:
--------------------------------------------------------------------------------
1 | # 7-Eleven Python implementation. This program allows you to lock in a fuel price from your computer.
2 | # Copyright (C) 2019 Freyta
3 | #
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
--------------------------------------------------------------------------------
/templates/confirm_price.html:
--------------------------------------------------------------------------------
1 | {% extends "index.html" %}
2 | {% block content %}
3 |
4 |
11 |
12 |
13 |
Hold on tight!
14 |
I am currently attempting to lock in your fuel price. This may take a minute or so...
15 |
16 | {% endblock %}
17 |
--------------------------------------------------------------------------------
/API_REQUESTS/login.py:
--------------------------------------------------------------------------------
1 | '''
2 | 7-Eleven Python implementation.
3 | An example of how to login with the API and print the accounts name.
4 |
5 | Copyright (C) 2019 Freyta
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | '''
17 |
18 | import api.creditcard as creditcard
19 | import api.account as account
20 | import api.fuellock as fuellock
21 | import api.giftcard as giftcard
22 | import json
23 |
24 | if __name__ == '__main__' :
25 | # We need to save the login details into a variable. When you login there are 3 details that 7-Eleven responds
26 | # with. They are your device secret token, access token and your account id.
27 | # Device secret and access token are used for almost every request to identify the user as you.
28 | myaccount = account.login("your@email.com","password")
29 |
30 | # Get your account details. The response is a JSON array.
31 | get_account_details = json.loads(account.getAccountDetails(myaccount[0],myaccount[1]))
32 | # Print the users first name
33 | print(get_account_details['PersonalDetails']['Name']['Firstname'])
34 |
35 | account.logout(myaccount[0],myaccount[1])
36 |
--------------------------------------------------------------------------------
/settings.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/python3
2 |
3 | # API_KEY: Google Maps with Geocoding API Key
4 | # Google Maps API is used to Geocode a Postcode to a logitude and latitude
5 | # To use the API a private API key is required.
6 | # Open the following URL (https://developers.google.com/maps/documentation/embed/get-api-key) to obtain a private API key
7 | # Ensure you have enabled the "Geocoding API"
8 |
9 | # The API_KEY is not needed as much anymore. It is only needed if you do not have a stores.json file where your script
10 | # is running from. But it should be automatically downloaded on first run anyway. The stores.json file is used to
11 | # determine the location of a 7Eleven stores and lock in around that area.
12 |
13 | API_KEY=""
14 |
15 | # TZ: All times are displayed using the chosen timezone. Choices for Australia are:
16 | # Australia/ACT
17 | # Australia/Adelaide
18 | # Australia/Brisbane
19 | # Australia/Broken_Hill
20 | # Australia/Canberra
21 | # Australia/Currie
22 | # Australia/Darwin
23 | # Australia/Eucla
24 | # Australia/Hobart
25 | # Australia/LHI
26 | # Australia/Lindeman
27 | # Australia/Lord_Howe
28 | # Australia/Melbourne
29 | # Australia/NSW
30 | # Australia/North
31 | # Australia/Perth
32 | # Australia/Queensland
33 | # Australia/South
34 | # Australia/Sydney
35 | # Australia/Tasmania
36 | # Australia/Victoria
37 | # Australia/West
38 | # Australia/Yancowinna
39 | TZ="UTC"
40 |
41 | # BASE_URL: 7-11 Mobile Application API End Point
42 | BASE_URL="https://711-goodcall.api.tigerspike.com/api/v1/"
43 |
44 | # PRICE_URL: 11-Seven Price API
45 | PRICE_URL="https://projectzerothree.info/api.php?format=json"
46 |
47 | # Device name - Samsung Galaxy S10. You can change this to any device you want.
48 | DEVICE_NAME="SM-G973FZKAXSA"
49 |
50 | # OS version
51 | OS_VERSION="Android 9.0.0"
52 |
53 | # App version
54 | APP_VERSION="1.10.0.2044"
55 |
56 | # Device id - A 16 character hexadecimal device identifier. You can change this to your own device ID
57 | # if you know it, otherwise a random one will be generated
58 | DEVICE_ID=""
59 |
--------------------------------------------------------------------------------
/API_REQUESTS/fuel_locks.py:
--------------------------------------------------------------------------------
1 | '''
2 | 7-Eleven Python implementation.
3 | An example of how to login with the API and show your current fuel lock.
4 |
5 | Copyright (C) 2019 Freyta
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | '''
17 |
18 | import api.account as account
19 | import api.fuellock as fuellock
20 | import json
21 |
22 | if __name__ == '__main__' :
23 | # We need to save the login details into a variable. When you login there are 3 details that 7-Eleven responds
24 | # with. They are your device secret token, access token and your account id.
25 | # Device secret and access token are used for almost every request to identify the user as you.
26 | myaccount = account.login("your@email.com","password")
27 |
28 | # Get your last fuel lock(s) into a JSON array.
29 | get_fuel_locks = json.loads(fuellock.listFuellock(myaccount[0],myaccount[1]))
30 |
31 | # Status codes:
32 | # 0 = ACTIVE
33 | # 1 = EXPIRED
34 | # 2 = REDEEMED
35 | if(get_fuel_locks[0]['Status'] == 2):
36 | # Get the details of the last fuel lock.
37 | get_last_lock_details = json.loads(fuellock.refreshFplData(myaccount[0], myaccount[1], get_fuel_locks[0]['Id']))
38 |
39 | print("You saved $" + str(get_last_lock_details['RewardAmount']) + ", while paying " + str(get_last_lock_details['CentsPerLitre']) + "cents per litre.")
40 | print("You filled up " + str(get_last_lock_details['RewardLitres'])[0:5] + " litres.")
41 |
42 | # And for good measure, logout.
43 | account.logout(myaccount[0],myaccount[1])
44 |
--------------------------------------------------------------------------------
/API_REQUESTS/add_credit.py:
--------------------------------------------------------------------------------
1 | '''
2 | 7-Eleven Python implementation.
3 | An example of how to login with the API and add credit to your account via credit card.
4 |
5 | Copyright (C) 2019 Freyta
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | '''
17 |
18 | import api.account as account
19 | import api.creditcard as creditcard
20 | import json
21 |
22 | if __name__ == '__main__' :
23 | # We need to save the login details into a variable. When you login there are 3 details that 7-Eleven responds
24 | # with. They are your device secret token, access token and your account id.
25 | # Device secret and access token are used for almost every request to identify the user as you.
26 | myaccount = account.login("your@email.com","password")
27 |
28 |
29 | # Get your credit card details
30 | ccdetails = creditcard.getCreditCards(myaccount[0], myaccount[1])
31 |
32 | # The amount you want to add must be either of the following options:
33 | # 10.00 , 20.00 , 30.00 , 40.00 , 50.00 , 60.00 , 70.00 , 80.00
34 | #
35 | # begin_transaction returns 2 variables. The first is TraceId which is used throughout the transaction
36 | # which acts as a session. The second is the URL which we need to go to to upload credit
37 | begin_transaction = creditcard.beginCCTransaction(ccdetails[0], "10.00", myaccount[0], myaccount[1])
38 |
39 | # Now we need to verify the transaction. Replace 123 with your CVV
40 | creditcard.verifyCcTransaction('123', begin_transaction[0], begin_transaction[1], myaccount[0], myaccount[1])
41 |
42 | # After we have loaded the pay URL, we then just need to load the confirmation page and our account is topped up!
43 | creditcard.confirmCreditCardTransaction(begin_transaction[0], begin_transaction[1], myaccount[0], myaccount[1])
44 |
45 | # And for good measure, logout.
46 | account.logout(myaccount[0],myaccount[1])
47 |
--------------------------------------------------------------------------------
/API_REQUESTS/api/giftcard.py:
--------------------------------------------------------------------------------
1 | '''
2 | 7-Eleven Python implementation.
3 |
4 | Copyright (C) 2019 Freyta
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 | You should have received a copy of the GNU General Public License
14 | along with this program. If not, see .
15 | '''
16 |
17 | from . import *
18 |
19 | def getDigitalCardBalance(deviceSecret, accessToken):
20 |
21 | tssa = generateTssa(BASE_URL + "GiftCard/Balance", "GET", "", accessToken)
22 |
23 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
24 | 'Connection':'Keep-Alive',
25 | 'Host':'711-goodcall.api.tigerspike.com',
26 | 'Authorization':'%s' % tssa,
27 | 'X-OsVersion':ANDROID_VERSION,
28 | 'X-OsName':'Android',
29 | 'X-DeviceID':DEVICE_ID,
30 | 'X-AppVersion':'1.7.0.2009',
31 | 'X-DeviceSecret':deviceSecret}
32 |
33 | response = requests.get(BASE_URL + "GiftCard/Balance", headers=headers)
34 |
35 | return(response.content)
36 |
37 | def getPhysicalCardBalance(deviceSecret, accessToken, GiftCardNumber, GiftCardPin):
38 |
39 | payload = '{"GiftCardNumber":' + GiftCardNumber + ',"GiftCardPin":"' + GiftCardPin + '"}'
40 | tssa = generateTssa(BASE_URL + "GiftCard/PhysicalBalance", "POST", payload, accessToken)
41 |
42 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
43 | 'Connection':'Keep-Alive',
44 | 'Host':'711-goodcall.api.tigerspike.com',
45 | 'Authorization':'%s' % tssa,
46 | 'X-OsVersion':ANDROID_VERSION,
47 | 'X-OsName':'Android',
48 | 'X-DeviceID':DEVICE_ID,
49 | 'X-AppVersion':'1.7.0.2009',
50 | 'X-DeviceSecret':deviceSecret,
51 | 'Content-Type':'application/json; charset=utf-8'}
52 |
53 | response = requests.get(BASE_URL + "GiftCard/PhysicalBalance", headers=headers)
54 |
55 | return(response.content)
56 |
57 |
58 |
59 | if __name__ == '__main__' :
60 | print("You should call the functions in this module from your main script")
61 |
--------------------------------------------------------------------------------
/API_REQUESTS/api/__init__.py:
--------------------------------------------------------------------------------
1 | '''
2 | 7-Eleven Python implementation.
3 |
4 | Copyright (C) 2019 Freyta
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 | You should have received a copy of the GNU General Public License
14 | along with this program. If not, see .
15 | '''
16 |
17 | import hashlib
18 | import hmac
19 | import base64
20 | import time
21 | import sys
22 | import uuid
23 | import requests
24 | import json
25 | import random
26 |
27 | ANDROID_VERSION = "Android 9.0.0"
28 | APP_VERSION = "1.10.0.2044"
29 | DEVICE_NAME = "OnePlus ONEPLUS A0001"
30 | BASE_URL = "https://711-goodcall.api.tigerspike.com/api/v1/"
31 | # Generate a random Device ID
32 | DEVICE_ID = ''.join(random.choice('0123456789abcdef') for i in range(15))
33 |
34 | # Used to decrypt the encryption keys
35 | def getKey():
36 |
37 | a = [103, 180, 267, 204, 390, 504, 497, 784, 1035, 520, 1155, 648, 988, 1456, 1785]
38 | b = [50, 114, 327, 276, 525, 522, 371, 904, 1017, 810, 858, 852, 1274, 1148, 915]
39 | c = [74, 220, 249, 416, 430, 726, 840, 568, 1017, 700, 1155, 912, 1118, 1372]
40 |
41 | length = len(a) + len(b) + len(c)
42 | key = ""
43 |
44 | for i in range(length):
45 | if(i % 3 == 0):
46 | key += chr( int((a[int(i / 3)] / ((i / 3) + 1)) ))
47 | if(i % 3 == 1):
48 | key += chr( int((b[int((i - 1) / 3)] / (((i - 1) / 3) + 1)) ))
49 | if(i % 3 == 2):
50 | key += chr( int((c[int((i - 1) / 3)] / (((i - 2) / 3) + 1)) ))
51 | return key
52 |
53 | # Encryption key used for the TSSA
54 | encryption_key = bytes(base64.b64decode(getKey()))
55 |
56 | # Generate the TSSA
57 | def generateTssa(URL, method, payload = None, accessToken = None):
58 |
59 | # Replace the https URL with a http one and convert the URL to lowercase
60 | URL = URL.replace("https", "http").lower()
61 | # Get a timestamp and a UUID
62 | timestamp = int(time.time())
63 | uuidVar = str(uuid.uuid4())
64 | # Join the variables into 1 string
65 | str3 = "yvktroj08t9jltr3ze0isf7r4wygb39s" + method + URL + str(timestamp) + uuidVar
66 | # If we have a payload to encrypt, then we encrypt it and add it to str3
67 | if(payload):
68 | payload = base64.b64encode(hashlib.md5(payload.encode()).digest())
69 | str3 += payload.decode()
70 |
71 | signature = base64.b64encode(hmac.new(encryption_key, str3.encode(), digestmod=hashlib.sha256).digest())
72 |
73 | # Finish building the tssa string
74 | tssa = "tssa yvktroj08t9jltr3ze0isf7r4wygb39s:" + signature.decode() + ":" + uuidVar + ":" + str(timestamp)
75 | # If we have an access token append it to the tssa string
76 | if(accessToken):
77 | tssa += ":" + accessToken
78 |
79 | return tssa
80 |
--------------------------------------------------------------------------------
/API_REQUESTS/muti_lock_in.py:
--------------------------------------------------------------------------------
1 | '''
2 | 7-Eleven Python implementation.
3 | An example of how to login with the API and add credit to your account via credit card.
4 |
5 | Copyright (C) 2019 Freyta
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | '''
17 |
18 | import api.account as account
19 | import api.fuellock as fuellock
20 | import requests, json
21 |
22 | def getCheapestFuel(fueltype):
23 | # Gets the cheapest fuel price for a certain type of fuel and the postcode
24 | # This is used for the automatic lock in
25 | r = requests.get("https://projectzerothree.info/api.php?format=json")
26 | response = json.loads(r.text)
27 | '''
28 | 52 = Unleaded 91
29 | 53 = Diesel
30 | 54 = LPG
31 | 55 = Unleaded 95
32 | 56 = Unleaded 98
33 | 57 = E10
34 | '''
35 | if(fueltype == "52"):
36 | fueltype = 1
37 | if(fueltype == "53"):
38 | fueltype = 4
39 | if(fueltype == "54"):
40 | fueltype = 5
41 | if(fueltype == "55"):
42 | fueltype = 2
43 | if(fueltype == "56"):
44 | fueltype = 3
45 | if(fueltype == "57"):
46 | fueltype = 0
47 |
48 | # Get the postcode and price
49 | postcode = response['regions'][0]['prices'][fueltype]['postcode']
50 | price = response['regions'][0]['prices'][fueltype]['price']
51 | latitude = response['regions'][0]['prices'][fueltype]['lat']
52 | longitude = response['regions'][0]['prices'][fueltype]['lng']
53 | return postcode, price, latitude, longitude
54 |
55 |
56 | if __name__ == '__main__' :
57 | # The fuel type we want. 56 is premium unleaded
58 | FUEL_TYPE = "56"
59 |
60 | # The email of all of our accounts
61 | accounts = ["first_email@gmail.com",
62 | "second_email@gmail.com",
63 | "third_email@gmail.com"]
64 |
65 | passwords = ["myfirstpassword",
66 | "thisispassword2",
67 | "andthethirdone"]
68 |
69 | # Combine the username and password together
70 | for user in zip(accounts, passwords):
71 | # Login to 7Eleven
72 | myaccount = account.login(user[0], user[1])
73 |
74 | # Get the cheapest fuel, and work out how much fuel we can lock in
75 | fuel_location = getCheapestFuel(FUEL_TYPE)
76 | litres = int(150)
77 |
78 | # Start the lock in session. Here you can confirm the price if you want
79 | # Note: You need to add the price confirmation yourself.
80 | fuellock.startLockinSession(myaccount[0], myaccount[1], fuel_location[2], fuel_location[3])
81 |
82 | # Lock in the price
83 | fuellock.confirmLockin(myaccount[0], myaccount[1], myaccount[2], FUEL_TYPE, litres)
84 |
85 | # And for good measure, just logout again
86 | account.logout(myaccount[0], myaccount[1])
87 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Note: I am archiving this project because I haven't touched anything to do with 7-Eleven in months, and haven't got the time to continue with this project. Thank you everyone who contributed, and I hope that you enjoyed this project. I've learned a lot. If you want to contact me, feel free to.
2 |
3 | # 7-Eleven Python
4 | What is this program? This is an extremely simple program to use that lets you lock in a fuel price from the comfort of your computer. Using this is easier than using the mock location removed APK that is floating around the internet because you do not need to use any other apps to fake a GPS location, and it universally works whether you are using an iPhone or an Android device! 7-Eleven Python will also automatically lock in the maximum amount of fuel that you are allowed to lock in. For instance if you have $38.97 in your account and fuel costs $1.13 a litre you will be able to lock in 35 litres.
5 | There is also a function that will automatically search a couple of websites for a reduction in fuel prices where if enabled, will automatically lock in that price for you. For example, if a service station has the price of Unleaded 98 for $1.28 per litre but only for an hour because it was a price error or they are out of normal unleaded fuel, it will still lock that price for you as long as the script is running in the background.
6 |
7 |
8 | # Setup
9 | Download Python3 from http://python.org/downloads/, and install it on your computer. It is a good idea to add Python to your PATH file after installing it, this makes it easier to run Python from any folder. To add Python to your Windows PATH you can follow this link https://geek-university.com/python/add-python-to-the-windows-path/.
10 |
11 | With Python installed, download the *pip* installer if you haven't installed it already. Follow the instructions here https://pip.readthedocs.io/en/latest/installing/#install-pip.
12 |
13 | Now that you have pip installed, you will need to install the dependencies in requirements.txt so that you can run the script. You can use the following pip command `pip install -r requirements.txt`.
14 |
15 | Optional: You can use a [Google Maps API key](https://developers.google.com/maps/documentation/embed/get-api-key) with the 'Geocoding API' enabled if you want to get a stores location via Google. You should set this key in settings.py or using the `API_KEY` environment variable described below.
16 |
17 | # Optional Security Setup
18 |
19 | Uncomment the basic authentication sections in app.py to enable a login prompt before accessing the site. Update the 'BASIC_AUTH_USERNAME' and 'BASIC_AUTH_PASSWORD' values to set the username and password.
20 |
21 | Uncomment the SSL section to enable HTTPS. Generate your own certificates using letsencrypt (https://letsencrypt.org/getting-started/) or generate a self signed certificate with OpenSSL.
22 |
23 | `openssl req -new -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes -out domain.crt -keyout domain.key`
24 |
25 | Copy the crt and key files to the same directory as app.py and uncomment the last line in app.py and comment the app.run line above.
26 |
27 | `app.run(host='0.0.0.0',port=443,ssl_context=context)`
28 |
29 | # Usage
30 | It's very simple to use 7-Eleven Python. Simply run the script with either of the following commands `python3 app.py` or `python app.py`. After you have started the program all you have to do is open your web browser and navigate to `http://[your-local-ip-address]:5000` i.e. `http://192.168.1.100:5000`. Then simply login with your 7-Eleven email and password, and click either automatic lock in or manually enter a postcode that you want to lock in from.
31 |
32 | # Docker Usage
33 | Clone the Git repo to your Docker host and build the image:
34 |
35 | `docker build -t fuellock .`
36 |
37 | Then run the image in a container:
38 |
39 |
43 |
44 | And browse to http://[Docker host IP]:5000
45 |
46 | Other environment variables you can specify at runtime:
47 |
48 | `BASE_URL`: The URL for the 7-Eleven API.
49 | `TZ`: Display time using the chosen timezone.
50 | `PRICE_URL`: The URL for the fuel price API (currently defaults to the API at projectzerothree.info)
51 | `DEVICE_NAME`: The name of the device reported on login to the 7-Eleven API (set by default in settings.py)
52 | `OS_VERSION`: The Android OS version reported on login to the 7-Eleven API (set by default in settings.py)
53 | `APP_VERSION`: The 7-Eleven app version reported on login to the 7-Eleven API (set by default in settings.py)
54 |
55 | An example of running with environmental variables is as follows:
56 |
57 |
114 | As of March 2020 you no longer require balance on your account to lock in fuel. Feel free to use up your balance when filling up, or in-store.
115 |
Special E10 cheapest price found was {{ session['price0'] }} at {{ session['postcode0'] }}
50 |
Special Unleaded cheapest price found was {{ session['price1'] }} at {{ session['postcode1'] }}
51 |
Extra 95 cheapest price found was {{ session['price2'] }} at {{ session['postcode2'] }}
52 |
Supreme+ 98 cheapest price found was {{ session['price3'] }} at {{ session['postcode3'] }}
53 |
Special Diesel cheapest price found was {{ session['price4'] }} at {{ session['postcode4'] }}
54 |
Autogas cheapest price found was {{ session['price5'] }} at {{ session['postcode5'] }}
55 |
56 |
57 |
74 |
75 |
76 |
89 |
90 |
91 |
92 |
This project was initially created by Freyta, but it takes a few people to maintain/update the code, so I would like to thank the following people as well (in alphabetical order):
I am currently attempting to lock in your fuel price. This may take a minute or so...
110 |
111 |
112 |
If you have any suggestions or additions you wish to submit, please make a pull request.
113 | If you encounter a problem or have an issue feel free to submit an issue.
114 |
115 | {% endif %}
116 | {% endblock %}
117 |
--------------------------------------------------------------------------------
/functions.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/python3
2 |
3 | # 7-Eleven Python implementation. This program allows you to lock in a fuel price from your computer.
4 | # Copyright (C) 2019 Freyta
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | # Functions used for the TSSA generation
20 | import hmac, base64, hashlib, uuid, time
21 | # Needed for the VmobID
22 | import pyDes
23 | # Functions used for setting our currently locked in fuel prices to the correct timezone
24 | import pytz, datetime
25 | # Used for requests to the price check script and for 7-Eleven stores
26 | import requests, json
27 | # Functions used for getting the OS environments from settings.py
28 | import settings, os
29 | # Needed for our randomly generated Device ID
30 | import random
31 | # Needed so we can set flask session variables
32 | from flask import session
33 |
34 |
35 | '''''''''''''''''''''''''''
36 | You can set or change any these environmental variables in settings.py
37 | '''''''''''''''''''''''''''
38 | API_KEY = os.getenv('API_KEY',settings.API_KEY)
39 | TZ = os.getenv('TZ', settings.TZ)
40 | BASE_URL = os.getenv('BASE_URL',settings.BASE_URL)
41 | PRICE_URL = os.getenv('PRICE_URL',settings.PRICE_URL)
42 | DEVICE_NAME = os.getenv('DEVICE_NAME', settings.DEVICE_NAME)
43 | OS_VERSION = os.getenv('OS_VERSION', settings.OS_VERSION)
44 | APP_VERSION = os.getenv('APP_VERSION', settings.APP_VERSION)
45 | USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
46 |
47 | def getKey():
48 | # Found in file au.com.seveneleven.y.h
49 | a = [103, 180, 267, 204, 390, 504, 497, 784, 1035, 520, 1155, 648, 988, 1456, 1785]
50 | # Found in file au.com.seveneleven.x.a
51 | b = [50, 114, 327, 276, 525, 522, 371, 904, 1017, 810, 858, 852, 1274, 1148, 915]
52 | # Found in file au.com.seveneleven.x.c
53 | c = [74, 220, 249, 416, 430, 726, 840, 568, 1017, 700, 1155, 912, 1118, 1372]
54 |
55 | # Get the length of all 3 variables
56 | length = len(a) + len(b) + len(c)
57 | key = ""
58 | # Generate the key with a bit of maths
59 | for i in range(length):
60 | if(i % 3 == 0):
61 | key += chr( int((a[int(i / 3)] / ((i / 3) + 1)) ))
62 | if(i % 3 == 1):
63 | key += chr( int((b[int((i - 1) / 3)] / (((i - 1) / 3) + 1)) ))
64 | if(i % 3 == 2):
65 | key += chr( int((c[int((i - 1) / 3)] / (((i - 2) / 3) + 1)) ))
66 |
67 | return key
68 |
69 | def generateTssa(URL, method, payload = None, accessToken = None):
70 |
71 | # Replace the https URL with a http one and convert the URL to lowercase
72 | URL = URL.replace("https", "http").lower()
73 | # Get a timestamp and a UUID
74 | timestamp = int(time.time())
75 | uuidVar = str(uuid.uuid4())
76 | # Join the variables into 1 string
77 | str3 = "yvktroj08t9jltr3ze0isf7r4wygb39s" + method + URL + str(timestamp) + uuidVar
78 | # If we have a payload to encrypt, then we encrypt it and add it to str3
79 | if(payload):
80 | payload = base64.b64encode(hashlib.md5(payload.encode()).digest())
81 | str3 += payload.decode()
82 |
83 | signature = base64.b64encode(hmac.new(encryption_key, str3.encode(), digestmod=hashlib.sha256).digest())
84 |
85 | # Finish building the tssa string
86 | tssa = "tssa yvktroj08t9jltr3ze0isf7r4wygb39s:" + signature.decode() + ":" + uuidVar + ":" + str(timestamp)
87 | # If we have an access token append it to the tssa string
88 | if(accessToken):
89 | tssa += ":" + accessToken
90 |
91 | return tssa
92 |
93 | def cheapestFuelAll():
94 | # Just a quick way to get fuel prices from a website that is already created.
95 | # Thank you to master131 for this.
96 | r = requests.get(PRICE_URL, headers={"user-agent":USER_AGENT})
97 | response = json.loads(r.text)
98 |
99 | # E10
100 | session['postcode0'] = response['regions'][0]['prices'][0]['postcode']
101 | session['price0'] = response['regions'][0]['prices'][0]['price']
102 |
103 | # Unleaded 91
104 | session['postcode1'] = response['regions'][0]['prices'][1]['postcode']
105 | session['price1'] = response['regions'][0]['prices'][1]['price']
106 |
107 | # Unleaded 95
108 | session['postcode2'] = response['regions'][0]['prices'][2]['postcode']
109 | session['price2'] = response['regions'][0]['prices'][2]['price']
110 |
111 | # Unleaded 98
112 | session['postcode3'] = response['regions'][0]['prices'][3]['postcode']
113 | session['price3'] = response['regions'][0]['prices'][3]['price']
114 |
115 | # Diesel
116 | session['postcode4'] = response['regions'][0]['prices'][4]['postcode']
117 | session['price4'] = response['regions'][0]['prices'][4]['price']
118 |
119 | # LPG
120 | session['postcode5'] = response['regions'][0]['prices'][5]['postcode']
121 | session['price5'] = response['regions'][0]['prices'][5]['price']
122 |
123 | def cheapestFuel(fueltype):
124 | # Gets the cheapest fuel price for a certain type of fuel and the postcode
125 | # This is used for the automatic lock in
126 | r = requests.get(PRICE_URL, headers={"user-agent":USER_AGENT})
127 | response = json.loads(r.text)
128 | '''
129 | 52 = Unleaded 91
130 | 53 = Diesel
131 | 54 = LPG
132 | 55 = Unleaded 95
133 | 56 = Unleaded 98
134 | 57 = E10
135 | '''
136 | if(fueltype == "52"):
137 | fueltype = 1
138 | if(fueltype == "53"):
139 | fueltype = 4
140 | if(fueltype == "54"):
141 | fueltype = 5
142 | if(fueltype == "55"):
143 | fueltype = 2
144 | if(fueltype == "56"):
145 | fueltype = 3
146 | if(fueltype == "57"):
147 | fueltype = 0
148 |
149 | # Get the postcode and price
150 | postcode = response['regions'][0]['prices'][fueltype]['postcode']
151 | price = response['regions'][0]['prices'][fueltype]['price']
152 | latitude = response['regions'][0]['prices'][fueltype]['lat']
153 | longitude = response['regions'][0]['prices'][fueltype]['lng']
154 | return postcode, price, latitude, longitude
155 |
156 | def lockedPrices():
157 | # This function is used for getting our locked in fuel prices to display on the main page
158 |
159 | # Remove all of our previous error messages
160 | session.pop('ErrorMessage', None)
161 |
162 | # Generate the tssa string
163 | tssa = generateTssa(BASE_URL + "FuelLock/List", "GET", None, session['accessToken'])
164 |
165 | # Assign the headers and then request the fuel prices.
166 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
167 | 'Authorization':'%s' % tssa,
168 | 'X-OsVersion':OS_VERSION,
169 | 'X-OsName':'Android',
170 | 'X-DeviceID':session['DEVICE_ID'],
171 | 'X-VmobID':des_encrypt_string(session['DEVICE_ID']),
172 | 'X-AppVersion':APP_VERSION,
173 | 'X-DeviceSecret':session['deviceSecret']}
174 |
175 | response = requests.get(BASE_URL + "FuelLock/List", headers=headers)
176 | returnContent = json.loads(response.content)
177 |
178 | # An error occours if we have never locked in a price before
179 | try:
180 | session['fuelLockId'] = returnContent[0]['Id']
181 | session['fuelLockStatus'] = returnContent[0]['Status']
182 | session['fuelLockActive'] = [0,0,0]
183 | session['fuelLockType'] = returnContent[0]['FuelGradeModel']
184 | session['fuelLockCPL'] = returnContent[0]['CentsPerLitre']
185 | session['fuelLockLitres'] = returnContent[0]['TotalLitres']
186 |
187 | tz = pytz.timezone(TZ)
188 |
189 | try:
190 | ts = returnContent[0]['RedeemedAt']
191 | session['fuelLockRedeemed'] = datetime.datetime.fromtimestamp(ts).astimezone(tz).strftime('%A %d %B %Y at %I:%M %p')
192 | except:
193 | session['fuelLockRedeemed'] = ""
194 |
195 | try:
196 | ts = returnContent[0]['ExpiresAt']
197 | session['fuelLockExpiry'] = datetime.datetime.fromtimestamp(ts).astimezone(tz).strftime('%A %d %B %Y at %I:%M %p')
198 | except:
199 | pass
200 |
201 | if(session['fuelLockStatus'] == 0):
202 | session['fuelLockActive'][0] = "Active"
203 |
204 | elif(session['fuelLockStatus'] == 1):
205 | session['fuelLockActive'][1] = "Expired"
206 |
207 | elif(session['fuelLockStatus'] == 2):
208 | session['fuelLockActive'][2] = "Redeemed"
209 |
210 | return session['fuelLockId'], session['fuelLockStatus'], session['fuelLockType'], session['fuelLockCPL'], session['fuelLockLitres'], session['fuelLockExpiry'], session['fuelLockRedeemed']
211 |
212 | except:
213 | # Since we haven't locked in a fuel price before
214 | session['fuelLockId'] = ""
215 | session['fuelLockStatus'] = ""
216 | session['fuelLockActive'] = ""
217 | session['fuelLockType'] = ""
218 | session['fuelLockCPL'] = ""
219 | session['fuelLockLitres'] = ""
220 | session['fuelLockRedeemed'] = ""
221 | session['fuelLockExpiry'] = ""
222 |
223 | return session['fuelLockId'], session['fuelLockStatus'], session['fuelLockType'], session['fuelLockCPL'], session['fuelLockLitres'], session['fuelLockExpiry'], session['fuelLockRedeemed']
224 |
225 |
226 |
227 |
228 | def getStores():
229 | # Get a list of all of the stores and their features from the 7-Eleven server.
230 | # We will use this for our coordinates for a manual lock in
231 | tssa = generateTssa(BASE_URL + "store/StoresAfterDateTime/1001", "GET")
232 | deviceID = ''.join(random.choice('0123456789abcdef') for i in range(16))
233 | # Assign the headers
234 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
235 | 'Authorization':'%s' % tssa,
236 | 'X-OsVersion':OS_VERSION,
237 | 'X-OsName':'Android',
238 | 'X-DeviceID':deviceID,
239 | 'X-VmobID':des_encrypt_string(deviceID),
240 | 'X-AppVersion':APP_VERSION}
241 |
242 | response = requests.get(BASE_URL + "store/StoresAfterDateTime/1001", headers=headers)
243 | return response.content
244 |
245 | def getStoreAddress(storePostcode):
246 | # Open the stores.json file and read it as a JSON file
247 | with open('./stores.json', 'r') as f:
248 | stores = json.load(f)
249 |
250 | # For each store in "Diffs" read the postcode
251 | for store in stores['Diffs']:
252 | #print store['PostCode']
253 | if(store['PostCode'] == storePostcode):
254 | # Since we have a match, return the latitude + longitude of our store
255 | return str(store['Latitude']), str(store['Longitude'])
256 |
257 | def des_encrypt_string(DEVICE_ID):
258 | # We only need the first 8 characters of the encryption key
259 | # Found in co.vmob.sdk.util.Utils.java
260 | key = 'co.vmob.sdk.android.encrypt.key'.encode()[:8]
261 |
262 | # The encryption prefix
263 | encryption_prefix = 'co.vmob.android.sdk.'
264 | # Now the encryption part
265 | cipher = pyDes.des(key, pyDes.ECB, pad=None, padmode=pyDes.PAD_PKCS5)
266 | encrypted_message = cipher.encrypt(encryption_prefix + DEVICE_ID)
267 |
268 | # Return the encrypted message base64 encoded and "decoded" so it is a string, not bytes.
269 | return base64.b64encode(encrypted_message).replace(b"/", b"_").decode() + "_"
270 |
271 | # Encryption key used for the TSSA
272 | encryption_key = bytes(base64.b64decode(getKey()))
273 | if __name__ == '__main__':
274 | print("This should be run through app.py")
275 |
--------------------------------------------------------------------------------
/autolocker.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/python3
2 |
3 | # 7-Eleven Python implementation. This program allows you to lock in a fuel price from your computer.
4 | # Copyright (C) 2019 Freyta
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | # Used to scrape ozbargain, and regex
20 | from bs4 import BeautifulSoup, re
21 | # Used for sending requests to 7-Eleven and getting the response in a JSON format
22 | import requests, json
23 | # Used to load details from the autolock.ini config file
24 | import configparser
25 | # Functions used for adding/subtracting from our coordinates and getting the time
26 | import time, random
27 | # Used for getting the variables and TSSA function etc
28 | import functions
29 |
30 | # Create the autolock.ini if the file doesn't exist.
31 | def create_ini():
32 | config = configparser.ConfigParser()
33 | config['General'] = {'auto_lock_enabled': 'False',
34 | 'max_price': '138.0'}
35 | config['Account'] = {'devicesecret': '',
36 | 'accesstoken': '',
37 | 'cardbalance': '',
38 | 'device_id': '',
39 | 'account_id': '',
40 | 'fuel_lock_saved': 'False'}
41 | config.write(open("autolock.ini","w"))
42 | print("autolock.ini wasn't found, so it was created.")
43 |
44 | # A function to search the (new) deals page to see if there is a post about 7-Eleven fuel prices
45 | def search_ozbargain():
46 | # We need to reiterate that suburb is global.. for some reason
47 | global suburb
48 |
49 | # Find 2 or 3 letters in the title surrounded by square brackets
50 | #regex_search = "(?=\[[A-Z]{2,3}\])"
51 |
52 | # The link to the deals page
53 | url = requests.get("https://www.ozbargain.com.au/deals").text
54 | # Open the deals page with BeautifulSoup
55 | soup = BeautifulSoup(url, "html.parser")
56 |
57 | # Find all deal posts with a title class
58 | response = soup.findAll('h2', class_="title")
59 |
60 | # Create a list to store all of the titles in case there is more than 1 current deal
61 | title = []
62 |
63 | for title_text in response:
64 | # If the words "7-Eleven" and "Fuel" is in the title, add it to our list
65 | # Adding "Fuel" should get rid of other deals posted
66 | if "7-Eleven" and "Fuel" in title_text.text:
67 | title.append(title_text.text)
68 |
69 | # Set suburb to none in case we don't find one later
70 | suburb = None
71 |
72 | # Search for the store location in the title of each deal
73 | for i in title:
74 | # Split after 7-Eleven to grab the store name (ignore text case)
75 | title_search = re.split("@ 7-Eleven", i, re.IGNORECASE)
76 | try:
77 | # Find a comma in
78 | suburb = re.sub("[^#@0-9A-Za-z ]+", "", title_search[1]).strip()
79 | except:
80 | suburb = title_search[1].strip()
81 |
82 | return suburb
83 |
84 | # Search ProjectZeroThree.info too.
85 | def search_pzt():
86 | # We need to reiterate that suburb is global.. for some reason
87 | global suburb
88 | # Load the ProjectZeroThree API into a JSON list
89 | url = requests.get(functions.PRICE_URL, headers={"user-agent":functions.USER_AGENT})
90 | # Find the cheapest price
91 | petrol_station = url.json()['regions'][0]['prices']
92 | # If the fuel type is U98 then get its suburb
93 | for i in petrol_station:
94 | if(i['type'] == "U98"):
95 | suburb = (i['suburb'])
96 |
97 | return suburb
98 |
99 | # Check if we have a current fuel lock
100 | def check_fuellock(accessToken, deviceSecret, DEVICE_ID):
101 | # Generate the tssa
102 | tssa = functions.generateTssa(functions.BASE_URL + "FuelLock/List", "GET", None, accessToken)
103 |
104 | # Assign the headers and then request the fuel prices.
105 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
106 | 'Authorization':'%s' % tssa,
107 | 'X-OsVersion':functions.OS_VERSION,
108 | 'X-OsName':'Android',
109 | 'X-DeviceID':DEVICE_ID,
110 | 'X-VmobID':functions.des_encrypt_string(DEVICE_ID),
111 | 'X-AppVersion':functions.APP_VERSION,
112 | 'X-DeviceSecret':deviceSecret}
113 |
114 | # Send the request and get the response into a JSON array
115 | response = requests.get(functions.BASE_URL + "FuelLock/List", headers=headers)
116 | returnContent = json.loads(response.content)
117 |
118 |
119 | config = configparser.ConfigParser()
120 | config.read("./autolock.ini")
121 | # If the Status of our last fuel lock is 0 (ACTIVE) set it to True, otherwise it has EXPIRED (1) or
122 | # was REDEEMED (2), so we haven't got a fuel lock saved.
123 | if(returnContent[0]['Status'] == 0):
124 | config.set('Account', 'fuel_lock_saved', "True")
125 | else:
126 | config.set('Account', 'fuel_lock_saved', "False")
127 |
128 | # Return our fuel lock saved boolean
129 | return config['Account'].getboolean('fuel_lock_saved')
130 |
131 | def start_lockin():
132 | config = configparser.ConfigParser()
133 | config.read("./autolock.ini")
134 | # Get the setting if auto_lock is true or false
135 | auto_lock_enabled = config['General'].getboolean('auto_lock_enabled')
136 | wanted_fuel_type = config['General'].getboolean('auto_lock_fuel_type')
137 | # Get the maximum price we want to pay for fuel
138 | max_price = config['General']['max_price']
139 | # Get our account details
140 | deviceSecret = config['Account']['deviceSecret']
141 | accessToken = config['Account']['accessToken']
142 | cardBalance = config['Account']['cardBalance']
143 | DEVICE_ID = config['Account']['DEVICE_ID']
144 |
145 | # Check if we have saved a fuel lock. We make a proper check here in case we have already locked in a price
146 | # without updating the autolock.ini for some reason.
147 | fuel_lock_saved = check_fuellock(accessToken, deviceSecret, DEVICE_ID)
148 |
149 | # If we have auto lock enabled, and are logged in but haven't saved a fuel lock yet, then proceed.
150 | if(auto_lock_enabled and deviceSecret and not fuel_lock_saved):
151 |
152 | # Search OzBargain for a new deal first, it may be posted there first
153 | if(not search_ozbargain()):
154 | # Search ProjectZeroThree since OzBargain has no results
155 | search_pzt()
156 |
157 | # If there is a location deal
158 | if(suburb):
159 | # Open the stores.json file so we can search it to find a store that (hopefully) matches
160 | with open('./stores.json', 'r') as f:
161 | stores = json.load(f)
162 |
163 | # For each store in "Diffs" read the postcode
164 | for store in stores['Diffs']:
165 | if(store['Suburb'] == suburb):
166 | # Since we have a match, return the latitude + longitude of our store and add a random number to it.
167 | latitude = store['Latitude']
168 | latitude += (random.uniform(0.01,0.000001) * random.choice([-1,1]))
169 | longitude = store['Longitude']
170 | longitude += (random.uniform(0.01,0.000001) * random.choice([-1,1]))
171 |
172 | # The payload to start the lock in process.
173 | payload = '{"LastStoreUpdateTimestamp":' + str(int(time.time())) + ',"Latitude":"' + str(latitude) + '","Longitude":"' + str(longitude) + '"}'
174 | tssa = functions.generateTssa(functions.BASE_URL + "FuelLock/StartSession", "POST", payload, accessToken)
175 |
176 | # Now we start the request header
177 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
178 | 'Authorization':'%s' % tssa,
179 | 'X-OsVersion':functions.OS_VERSION,
180 | 'X-OsName':'Android',
181 | 'X-DeviceID':DEVICE_ID,
182 | 'X-VmobID':functions.des_encrypt_string(DEVICE_ID),
183 | 'X-AppVersion':functions.APP_VERSION,
184 | 'X-DeviceSecret':deviceSecret,
185 | 'Content-Type':'application/json; charset=utf-8'}
186 |
187 | # Send the request
188 | response = requests.post(functions.BASE_URL + "FuelLock/StartSession", data=payload, headers=headers)
189 |
190 | # Get the response content so we can check the fuel price
191 | returnContent = response.content
192 |
193 | # Move the response json into an array so we can read it
194 | returnContent = json.loads(returnContent)
195 |
196 | # If there is a fuel lock already in place we get an error!
197 | try:
198 | if returnContent['ErrorType'] == 0:
199 | # Print that we have a lock in already
200 | print("Tried to lock in, but we already have a lock in saved.")
201 | except:
202 | # Get the fuel price of all the types of fuel
203 | for each in returnContent['CheapestFuelTypeStores']:
204 | x = each['FuelPrices']
205 | for i in x:
206 | # If the fuel type is the one we are after
207 | if(i['Ean'] == str(wanted_fuel_type)):
208 | # Save the fuel pump price
209 | pump_price = i['Price']
210 |
211 | # If the price that we tried to lock in is more expensive than scripts price, we return an error
212 | if (float(pump_price) >= float(max_price)):
213 | print("There was a new deal posted, but the fuel price was too expensive. You want to fill up for less than {0}c, it would have been {1}c.".format(str(max_price), str(pump_price)))
214 | else:
215 | # Now we want to lock in the maximum litres we can.
216 | NumberOfLitres = int(float(config['Account']['cardbalance']) / pump_price * 100)
217 |
218 | # Lets start the actual lock in process
219 | payload = '{"AccountId":"' + config['Account']['account_id'] + '","FuelType":' + str(wanted_fuel_type) + ',"NumberOfLitres":"' + str(NumberOfLitres) + '"}'
220 |
221 | tssa = functions.generateTssa(functions.BASE_URL + "FuelLock/Confirm", "POST", payload, accessToken)
222 |
223 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
224 | 'Authorization':'%s' % tssa,
225 | 'X-OsVersion':functions.OS_VERSION,
226 | 'X-OsName':'Android',
227 | 'X-DeviceID':DEVICE_ID,
228 | 'X-VmobID':functions.des_encrypt_string(DEVICE_ID),
229 | 'X-AppVersion':functions.APP_VERSION,
230 | 'X-DeviceSecret':deviceSecret,
231 | 'Content-Type':'application/json; charset=utf-8'}
232 |
233 | # Send through the request and get the response
234 | response = requests.post(functions.BASE_URL + "FuelLock/Confirm", data=payload, headers=headers)
235 | returnContent = json.loads(response.content)
236 |
237 | try:
238 | if(returnContent['Message']):
239 | print("Error: There was an error locking in.")
240 | except:
241 | print("Success! Locked in {0}L at {1} cents per litre".format(str(returnContent['TotalLitres']), str(returnContent['CentsPerLitre'])))
242 | if __name__ == '__main__':
243 | # Make the variable suburb global
244 | global suburb
245 | suburb = None
246 | print("This should be run through app.py")
247 |
--------------------------------------------------------------------------------
/static/css/style.css:
--------------------------------------------------------------------------------
1 | /*--
2 | Author: W3layouts
3 | Author URL: http://w3layouts.com
4 | License: Creative Commons Attribution 3.0 Unported
5 | License URL: http://creativecommons.org/licenses/by/3.0/
6 | --*/
7 | /* reset */
8 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,dl,dt,dd,ol,nav ul,nav li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;}
9 | article, aside, details, figcaption, figure,footer, header, hgroup, menu, nav, section {display: block;}
10 | ol,ul{list-style:none;margin:0px;padding:0px;}
11 | blockquote,q{quotes:none;}
12 | blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;}
13 | table{border-collapse:collapse;border-spacing:0;}
14 | /* start editing from here */
15 | a{text-decoration:none;}
16 | .txt-rt{text-align:right;}/* text align right */
17 | .txt-lt{text-align:left;}/* text align left */
18 | .txt-center{text-align:center;}/* text align center */
19 | .float-rt{float:right;}/* float right */
20 | .float-lt{float:left;}/* float left */
21 | .clear{clear:both;}/* clear float */
22 | .pos-relative{position:relative;}/* Position Relative */
23 | .pos-absolute{position:absolute;}/* Position Absolute */
24 | .vertical-base{ vertical-align:baseline;}/* vertical align baseline */
25 | .vertical-top{ vertical-align:top;}/* vertical align top */
26 | nav.vertical ul li{ display:block;}/* vertical menu */
27 | nav.horizontal ul li{ display: inline-block;}/* horizontal menu */
28 | img{max-width:100%;}
29 | /*end reset*/
30 | html, body{
31 | color: white;
32 | margin:0;
33 | font-size: 100%;
34 | font-family: 'Open Sans', sans-serif;
35 | }
36 | body a {
37 | text-decoration:none;
38 | transition:0.5s all;
39 | -webkit-transition:0.5s all;
40 | -moz-transition:0.5s all;
41 | -o-transition:0.5s all;
42 | -ms-transition:0.5s all;
43 | }
44 | a:hover{
45 | text-decoration:none;
46 | }
47 | @font-face {
48 | font-family: 'PoiretOne-Regular';
49 | src: url(../fonts/PoiretOne-Regular.ttf)format('truetype');
50 | }
51 |
52 | h1,h2,h3,h4,h5,h6{
53 | margin:0;
54 | }
55 | p{
56 | margin:0;
57 | }
58 | select {
59 | color: #1b304a;
60 | }
61 | hr{
62 | border-top: 1px dotted;
63 | color: rgb(255, 255, 255);
64 | margin: 10px;
65 | width: 200px;
66 | }
67 | #automatic{
68 | display: none;
69 | margin-top: 0px;
70 | top: 0px;
71 | }
72 | #manual{
73 | display: none;
74 | margin-top: 0px;
75 | top: 0px;
76 | }
77 | #settings{
78 | display: none;
79 | margin-top: 0px;
80 | top: 0px;
81 | }
82 | #credits{
83 | margin-top: 0px;
84 | top: 0px;
85 | }
86 | #buttonpressed{
87 | display: none;
88 | margin-top: 0px;
89 | top: 0px;
90 | }
91 | .bold_balance{
92 | font-weight: bold;
93 | }
94 | .username_link{
95 | font-weight: bold;
96 | color: lightgrey;
97 | }
98 | .not_found{
99 | padding: 1em;
100 | margin-top: 1.5em;
101 | background-color: rgb(255, 255, 255);
102 | }
103 | .not_found_title{
104 | margin-bottom: 1.5em;
105 | text-decoration: underline;
106 | font-weight: bold;
107 | }
108 | .find_username_text{
109 | display: none;
110 | margin-top: 0.5em;
111 | background-color: rgb(255, 255, 255);
112 | padding: 1em;
113 | }
114 | .find_username_text li {
115 | list-style-type: circle;
116 | list-style-position: inside;
117 | font-size: small;
118 | }
119 | .find_username_link{
120 | margin-top: 0.5em;
121 | }
122 | .playlist {
123 | margin-bottom: 1.5em;
124 | list-style-type: circle;
125 | list-style-position: inside;
126 | }
127 | .playlist_track {
128 | color: #fff;
129 | }
130 | .loader {
131 | color: #ffffff;
132 | font-size: 90px;
133 | text-indent: -9999em;
134 | overflow: hidden;
135 | width: 1em;
136 | height: 1em;
137 | border-radius: 50%;
138 | margin: 72px auto;
139 | position: relative;
140 | -webkit-transform: translateZ(0);
141 | -ms-transform: translateZ(0);
142 | transform: translateZ(0);
143 | -webkit-animation: load6 1.7s infinite ease;
144 | animation: load6 1.7s infinite ease;
145 | }
146 | @-webkit-keyframes load6 {
147 | 0% {
148 | -webkit-transform: rotate(0deg);
149 | transform: rotate(0deg);
150 | box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
151 | }
152 | 5%,
153 | 95% {
154 | box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
155 | }
156 | 10%,
157 | 59% {
158 | box-shadow: 0 -0.83em 0 -0.4em, -0.087em -0.825em 0 -0.42em, -0.173em -0.812em 0 -0.44em, -0.256em -0.789em 0 -0.46em, -0.297em -0.775em 0 -0.477em;
159 | }
160 | 20% {
161 | box-shadow: 0 -0.83em 0 -0.4em, -0.338em -0.758em 0 -0.42em, -0.555em -0.617em 0 -0.44em, -0.671em -0.488em 0 -0.46em, -0.749em -0.34em 0 -0.477em;
162 | }
163 | 38% {
164 | box-shadow: 0 -0.83em 0 -0.4em, -0.377em -0.74em 0 -0.42em, -0.645em -0.522em 0 -0.44em, -0.775em -0.297em 0 -0.46em, -0.82em -0.09em 0 -0.477em;
165 | }
166 | 100% {
167 | -webkit-transform: rotate(360deg);
168 | transform: rotate(360deg);
169 | box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
170 | }
171 | }
172 | @keyframes load6 {
173 | 0% {
174 | -webkit-transform: rotate(0deg);
175 | transform: rotate(0deg);
176 | box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
177 | }
178 | 5%,
179 | 95% {
180 | box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
181 | }
182 | 10%,
183 | 59% {
184 | box-shadow: 0 -0.83em 0 -0.4em, -0.087em -0.825em 0 -0.42em, -0.173em -0.812em 0 -0.44em, -0.256em -0.789em 0 -0.46em, -0.297em -0.775em 0 -0.477em;
185 | }
186 | 20% {
187 | box-shadow: 0 -0.83em 0 -0.4em, -0.338em -0.758em 0 -0.42em, -0.555em -0.617em 0 -0.44em, -0.671em -0.488em 0 -0.46em, -0.749em -0.34em 0 -0.477em;
188 | }
189 | 38% {
190 | box-shadow: 0 -0.83em 0 -0.4em, -0.377em -0.74em 0 -0.42em, -0.645em -0.522em 0 -0.44em, -0.775em -0.297em 0 -0.46em, -0.82em -0.09em 0 -0.477em;
191 | }
192 | 100% {
193 | -webkit-transform: rotate(360deg);
194 | transform: rotate(360deg);
195 | box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
196 | }
197 | }
198 | .login-spotify {
199 | text-align: center;
200 | }
201 | .login-spotify img {
202 | max-width: 70%;
203 | }
204 | .profile-top {
205 | background: rgb(00, 80, 61);
206 | padding: 1.5em;
207 | }
208 | .pic{
209 | float:left;
210 | width:25%;
211 | }
212 | .pic img{
213 | width:100%;
214 | border-radius:50%;
215 | border:5px solid #fff;
216 | }
217 | .pic_info{
218 | float:left;
219 | width:65%;
220 | margin-left:10%;
221 | text-align:left;
222 | /*padding-top: 2em;*/
223 | }
224 | .pic_info h2{
225 | color:#fff;
226 | font-size:1.5em;
227 | font-weight: 600;
228 | }
229 | .pic_info h3{
230 | font-size:1em;
231 | margin-top:0.5em;
232 | }
233 | .pic_info h3 a{
234 | color:#7489a2;
235 | text-decoration:none;
236 | }
237 | .media{
238 | margin-top:1em;
239 | padding-top:1em;
240 | border-top:1px solid rgb(255, 255, 255);
241 | }
242 | .media h2 {
243 | color: #fff;
244 | font-size: 1.3em;
245 | font-weight: 600;
246 | margin-bottom: 1em;
247 | }
248 | .tweet{
249 | width:33.3%;
250 | float:left;
251 | }
252 | .tweet h4,.follow h4,.follow2 h4{
253 | color:#fff;
254 | font-size:1.4em;
255 | font-weight:600;
256 | }
257 | .tweet h5,.follow h5,.follow2 h5{
258 | color:#fff;
259 | font-size:1.1em;
260 | text-transform:uppercase;
261 | }
262 | .follow{
263 | width:33.3%;
264 | float:left;
265 | }
266 | .follow2{
267 | width:33.3%;
268 | float:left;
269 | }
270 | .profile {
271 | margin-top:3em;
272 | }
273 | .profile-bottom ul li{
274 | list-style: none;
275 | text-align: left;
276 | border-bottom:1px ridge #DFDFDF;
277 | }
278 | .profile-bottom ul li:nth-child(6){
279 | border-bottom:none;
280 | }
281 | .profile-bottom ul li a{
282 | padding: 17px 20px;
283 | margin: 0;
284 | display: block;
285 | background:#f5f5f5;
286 | color:#8c8c8c;
287 | font-size:1.1em;
288 | transition: 0.5s all;
289 | -webkit-transition: 0.5s all;
290 | -moz-transition: 0.5s all;
291 | -o-transition: 0.5s all;
292 | }
293 | .profile-bottom ul li a:hover{
294 | color:#fff;
295 | background: #1a2c4d;
296 | }
297 | /*-- w3layouts --*/
298 | .profile-bottom ul li i {
299 | background: #374559;
300 | float: right;
301 | padding: 4px 12px;
302 | font-size: 13px;
303 | display: block;
304 | color:#fff;
305 | border-radius: 4px;
306 | -webkit-border-radius: 4px;
307 | -moz-border-radius: 4px;
308 | -o-border-radius: 4px;
309 | font-style: normal;
310 | }
311 | /*-- main --*/
312 | .audio-record-list {
313 | margin:0 auto;
314 | width: 700px;
315 | }
316 | .audio-main {
317 | padding:6em 0 2em 0;
318 | }
319 | .audio-main h1{
320 | text-align: center;
321 | font-family: 'PoiretOne-Regular';
322 | font-size: 50px;
323 | color: #000000;
324 | font-weight: 600;
325 | margin-bottom:40px;
326 | }
327 | .audio-main p{
328 | margin-bottom:2em;
329 | line-height:1.8em;
330 | color: #fff;
331 | font-size: 14px;
332 | text-align: center;
333 | }
334 | .audio-main p {
335 | margin: 4em 0 1em;
336 | line-height: 1.8em;
337 | color: #000;
338 | font-size: 14px;
339 | text-align: center;
340 | }
341 | .audio-main p a{
342 | color:#000;
343 | text-decoration:none;
344 | }
345 | .audio-main p a:hover{
346 | color:#fff;
347 | }
348 | /*-- agileits --*/
349 | /*-- //main --*/
350 | /*-- responsive media queries --*/
351 | @media (max-width: 1680px){
352 | .audio-main {
353 | padding: 4em 0 0em 0;
354 | }
355 | .audio-main h1 {
356 | margin-bottom: 60px;
357 | }
358 | }
359 | @media (max-width: 1600px){
360 | }
361 | @media (max-width: 1440px){
362 | .audio-main h1 {
363 | margin-bottom: 75px;
364 | }
365 | }
366 | @media (max-width: 1366px){
367 | .audio-main {
368 | padding: 4.2em 0 2em 0;
369 | }
370 | }
371 | @media (max-width: 1280px){
372 | .audio-main h1 {
373 | margin-bottom: 40px;
374 | }
375 | }
376 | @media (max-width: 1200px){
377 | .audio-main h1 {
378 | font-size: 47px;
379 | }
380 | }
381 | @media (max-width: 1080px){
382 | .audio-main {
383 | padding: 5em 0 2em 0;
384 | }
385 | .audio-main h1 {
386 | font-size: 45px;
387 | }
388 | }
389 | /*-- w3layouts --*/
390 | @media (max-width: 1050px){
391 | }
392 | @media (max-width: 1024px){
393 | .audio-main p {
394 | margin-bottom:2em;
395 | }
396 | .audio-main {
397 | padding: 4em 0 2em 0;
398 | }
399 | .audio-main h1 {
400 | font-size: 42px;
401 | }
402 | }
403 | @media (max-width: 991px){
404 | .audio-main {
405 | padding: 3em 0 0em 0;
406 | }
407 | .audio-main h1 {
408 | margin-bottom: 35px;
409 | font-size: 36px;
410 | }
411 | }
412 | @media (max-width: 800px){
413 | .audio-record-list {
414 | width: 80%;
415 | }
416 | }
417 | @media (max-width: 768px){
418 | .audio-main h1 {
419 | margin-bottom: 32px;
420 | font-size: 32px;
421 | }
422 | }
423 | @media (max-width: 736px){
424 | .audio-record-list {
425 | width:75%;
426 | }
427 | }
428 | @media (max-width: 667px){
429 | }
430 | @media (max-width: 640px){
431 | .audio-record-list {
432 | width: 80%;
433 | }
434 | }
435 | /*-- agileits --*/
436 | @media (max-width: 600px){
437 | .audio-record-list {
438 | width: 72%;
439 | }
440 | }
441 | @media (max-width: 568px){
442 | .audio-main p {
443 | font-size: 13px;
444 | }
445 | .audio-record-list {
446 | width: 74%;
447 | }
448 | }
449 | @media (max-width: 480px){
450 | .audio-record-list {
451 | width: 74%;
452 | }
453 | .audio-main h1 {
454 | margin-bottom: 26px;
455 | font-size: 26px;
456 | }
457 | .tweet h4, .follow h4, .follow2 h4 {
458 | font-size: 1.2em;
459 | }
460 | .tweet h5, .follow h5, .follow2 h5 {
461 | font-size: 0.85em;
462 | }
463 | }
464 | @media(max-width:414px){
465 | .audio-record-list {
466 | width: 84%;
467 | }
468 | .pic {
469 | float: none;
470 | width: 58%;
471 | margin: 0 auto;
472 | }
473 | .pic_info {
474 | float: none;
475 | width: 100%;
476 | margin-left: 0;
477 | text-align: center;
478 | padding-top: 1em;
479 | }
480 | }
481 | @media(max-width:384px){
482 | .audio-record-list {
483 | width: 88%;
484 | }
485 | .profile {
486 | margin-top: 1.5em;
487 | }
488 | .audio-main p {
489 | padding: 0 10px;
490 | }
491 | }
492 | @media(max-width:375px){
493 | .audio-record-list {
494 | width: 87%;
495 | }
496 | }
497 | @media(max-width:320px){
498 | .audio-main {
499 | padding: 1.5em 0 0em 0;
500 | }
501 | .audio-main h1 {
502 | font-size: 23px;
503 | }
504 |
505 | .tweet h4, .follow h4, .follow2 h4 {
506 | font-size: 1.1em;
507 | }
508 | .profile-top {
509 | padding: 0.8em;
510 | }
511 | .tweet h5, .follow h5, .follow2 h5 {
512 | font-size: 0.7em;
513 | }
514 | .pic_info h2 {
515 | font-size: 1.3em;
516 | }
517 | .pic_info h3 {
518 | font-size: 1em;
519 | }
520 | .audio-main p {
521 | padding: 0 0px;
522 | }
523 | }
524 | /*-- //responsive media queries --*/
525 |
526 | /* PLAYLIST */
527 | /* CSS Transitions */
528 | * {
529 | -moz-transition:all 100ms ease;
530 | -o-transition:all 100ms ease;
531 | -webkit-transition:all 100ms ease;
532 | transition:all 100ms ease;
533 | }
534 |
535 | /* Audio Player Styles
536 | ================================================== */
537 |
538 | /* Default / Desktop / Firefox */
539 | #plwrap { margin:0 auto; }
540 | #plList { margin:0; }
541 | #plList li { cursor:pointer; margin:0; padding:21px 0; }
542 | #plList li:hover { background-color: rgb(255,255,255); }
543 | .plItem { position:relative; }
544 | .plTitle { left:50px; overflow:hidden; position:absolute; right:131px; text-overflow:ellipsis; top:0; white-space:nowrap; }
545 | .plNum { padding-left:21px; width:25px; }
546 | .plLength { width: 110px; padding-left:5px; position:absolute; right:21px; top:0; text-align: right; }
547 |
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | #-*- coding: utf8 -*-
2 | #! /usr/bin/python3
3 |
4 |
5 | # 7-Eleven Python implementation. This program allows you to lock in a fuel price from your computer.
6 | # Copyright (C) 2019 Freyta
7 | #
8 | # This program is free software: you can redistribute it and/or modify
9 | # it under the terms of the GNU General Public License as published by
10 | # the Free Software Foundation, either version 3 of the License, or
11 | # (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful,
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | # GNU General Public License for more details.
17 | #
18 | # You should have received a copy of the GNU General Public License
19 | # along with this program. If not, see .
20 |
21 |
22 | from flask import Flask, render_template, request, redirect, url_for, session, flash
23 |
24 | # Optional Security
25 | # Uncomment Basic Auth section to enable basic authentication so users will be prompted a username and password before seeing the website.
26 | #from flask_basicauth import BasicAuth
27 |
28 | # Uncomment SSL section to enable HTTPS (certificates required)
29 | #import ssl
30 | #context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
31 | #context.load_cert_chain('domain.crt', 'domain.key')
32 |
33 | # Used for getting/settings the OS environments and for writing/reading the stores.json file
34 | import sys, os, time
35 | # Used for sending requests to 7-Eleven and getting the response in a JSON format.
36 | import requests, json
37 | # Used for our randomly generated Device ID (if needed)
38 | import random
39 | # Used to set our coordinates while locking in a price
40 | import googlemaps
41 | # Used for all of our custom settings and functions
42 | import settings, functions
43 | # Used for the auto locking function
44 | from apscheduler.schedulers.background import BackgroundScheduler
45 | # Used to load and save details from the autolock.ini config file and import our autolocker
46 | import autolocker, configparser
47 |
48 |
49 | # If we haven't set the API key or it is it's default value, warn the user that we will disable the Google Maps search.
50 | if(functions.API_KEY in [None,"changethis",""]):
51 | custom_coords = False
52 | print("Note: You have not set an API key. You will not be able to use Google to find a stores coordinates.\nBut you can still use the manual search if you know the postcode to the store you want to lock in from.\n\n\n\n\n")
53 |
54 | # If we have not set a device ID then let them know a random one will be generated
55 | if(os.getenv('DEVICE_ID', settings.DEVICE_ID) in [None,"changethis",""]):
56 | print("Note: You have not set a device ID. A random one will be set when you login.")
57 |
58 |
59 |
60 | app = Flask(__name__)
61 |
62 | # Uncomment to enable basic authentication
63 | #app.config['BASIC_AUTH_FORCE'] = True
64 | #app.config['BASIC_AUTH_USERNAME'] = 'petrol'
65 | #app.config['BASIC_AUTH_PASSWORD'] = 'lockit'
66 | #basic_auth = BasicAuth(app)
67 |
68 | @app.route('/')
69 | def index():
70 |
71 | # If they have pressed the refresh link remove the error and success messages
72 | if(request.args.get('action') == "refresh"):
73 | session.pop('ErrorMessage', None)
74 | session.pop('SuccessMessage', None)
75 | session.pop('fuelType', None)
76 | session.pop('LockinPrice', None)
77 | try:
78 | # Regenerate our locked in prices
79 | functions.lockedPrices()
80 | except:
81 | # If there was an error, lets just move on.
82 | pass
83 |
84 | # If the environmental variable DEVICE_ID is empty or is not set at all
85 | if(os.getenv('DEVICE_ID', settings.DEVICE_ID) in [None,"changethis",""]):
86 | # Set the device id to a randomly generated one
87 | DEVICE_ID = ''.join(random.choice('0123456789abcdef') for i in range(16))
88 | else:
89 | # Otherwise we set the it to the one set in settings.py
90 | DEVICE_ID = os.getenv('DEVICE_ID', settings.DEVICE_ID)
91 |
92 | # Set the session max price for the auto locker
93 | session['max_price'] = config['General']['max_price']
94 |
95 | # Get the cheapest fuel price to show on the automatic lock in page
96 | fuelPrice = functions.cheapestFuelAll()
97 |
98 | return render_template('price.html',device_id=DEVICE_ID)
99 |
100 |
101 |
102 | @app.route('/login', methods=['POST', 'GET'])
103 | def login():
104 | # Clear the error and success message
105 | session.pop('ErrorMessage', None)
106 | session.pop('SuccessMessage', None)
107 | session.pop('fuelType', None)
108 |
109 | if request.method == 'POST':
110 | # If the device ID field was left blank, set a random one
111 | if ((request.form['device_id']) in [None,""]):
112 | session['DEVICE_ID'] = os.getenv('DEVICE_ID', ''.join(random.choice('0123456789abcdef') for i in range(16)))
113 | else:
114 | # Since it was filled out, we will use that for the rest of the session
115 | session['DEVICE_ID'] = os.getenv('DEVICE_ID', request.form['device_id'])
116 |
117 | # Get the email and password from the login form
118 | password = str(request.form['password'])
119 | email = str(request.form['email'])
120 |
121 | # The payload that we use to login
122 | payload = '{"Email":"' + email + '","Password":"' + password + '","DeviceName":"' + functions.DEVICE_NAME + '","DeviceOsNameVersion":"' + functions.OS_VERSION +'"}'
123 |
124 | # Generate the tssa string
125 | tssa = functions.generateTssa(functions.BASE_URL + "account/login", "POST", payload)
126 |
127 | # Assign the headers
128 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
129 | 'Authorization':'%s' % tssa,
130 | 'X-OsVersion':functions.OS_VERSION,
131 | 'X-OsName':'Android',
132 | 'X-DeviceID':session['DEVICE_ID'],
133 | 'X-VmobID':functions.des_encrypt_string(session['DEVICE_ID']),
134 | 'X-AppVersion':functions.APP_VERSION,
135 | 'Content-Type':'application/json; charset=utf-8'}
136 |
137 | # Login now!
138 | response = requests.post(functions.BASE_URL + "account/login", data=payload, headers=headers)
139 |
140 | returnHeaders = response.headers
141 | returnContent = json.loads(response.text)
142 |
143 | try:
144 | # If there was an error logging in, redirect to the index page with the 7Eleven response
145 | if(returnContent['Message']):
146 | session['ErrorMessage'] = returnContent['Message']
147 | return redirect(url_for('index'))
148 |
149 | except:
150 |
151 | # We need the AccessToken from the response header
152 | accessToken = str(returnHeaders).split("'X-AccessToken': '")
153 | accessToken = accessToken[1].split("'")
154 | accessToken = accessToken[0]
155 |
156 | # DeviceSecretToken and accountID are both needed to lock in a fuel price
157 | deviceSecret = returnContent['DeviceSecretToken']
158 | accountID = returnContent['AccountId']
159 | # Save the users first name and their card balance so we can display it
160 | firstName = returnContent['FirstName']
161 | cardBalance = str(returnContent['DigitalCard']['Balance'])
162 |
163 | session['deviceSecret'] = deviceSecret
164 | session['accessToken'] = accessToken
165 | session['accountID'] = accountID
166 | session['firstName'] = firstName
167 | session['cardBalance'] = cardBalance
168 |
169 |
170 | functions.lockedPrices()
171 |
172 |
173 | # If we have ticked enable auto lock in, then set boolean to true
174 | if(request.form.getlist('auto_lockin')):
175 | config.set('General', 'auto_lock_enabled', "True")
176 | session['auto_lock'] = True
177 | else:
178 | # We didn't want to save it, so set to false
179 | config.set('General', 'auto_lock_enabled', "False")
180 | session['auto_lock'] = False
181 |
182 | # Save their log in anyway, so we can update the auto lock option later if needed
183 | config.set('Account', 'deviceSecret', session['deviceSecret'])
184 | config.set('Account', 'accessToken', session['accessToken'])
185 | config.set('Account', 'cardBalance', session['cardBalance'])
186 | config.set('Account', 'account_ID', session['accountID'])
187 | config.set('Account', 'DEVICE_ID', session['DEVICE_ID'])
188 |
189 | # If we have an active fuel lock, set fuel_lock_saved to true, otherwise false
190 | if(session['fuelLockStatus'] == 0):
191 | config.set('Account', 'fuel_lock_saved', "True")
192 | else:
193 | config.set('Account', 'fuel_lock_saved', "False")
194 | # Write the config to file
195 | with open('./autolock.ini', 'w') as configfile:
196 | config.write(configfile)
197 |
198 | return redirect(url_for('index'))
199 | else:
200 | # They didn't submit a POST request, so we will redirect to index
201 | return redirect(url_for('index'))
202 |
203 |
204 | @app.route('/logout')
205 | def logout():
206 |
207 | # The logout payload is an empty string but it is still needed
208 | payload = '""'
209 | tssa = functions.generateTssa(functions.BASE_URL + "account/logout", "POST", payload, session['accessToken'])
210 |
211 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
212 | 'Authorization':'%s' % tssa,
213 | 'X-OsVersion':functions.OS_VERSION,
214 | 'X-OsName':'Android',
215 | 'X-DeviceID':session['DEVICE_ID'],
216 | 'X-VmobID':functions.des_encrypt_string(session['DEVICE_ID']),
217 | 'X-AppVersion':functions.APP_VERSION,
218 | 'X-DeviceSecret':session['deviceSecret'],
219 | 'Content-Type':'application/json; charset=utf-8'}
220 |
221 | response = requests.post(functions.BASE_URL + "account/logout", data=payload, headers=headers)
222 |
223 | # Clear all of the previously set session variables and then redirect to the index page
224 | session.clear()
225 |
226 | return redirect(url_for('index'))
227 |
228 | # The confirmation page for a manual lock in
229 | @app.route('/confirm')
230 | def confirm():
231 | # See if we have a temporary lock in price
232 | try:
233 | if(session['LockinPrice']):
234 | # Since we do, show the confirmation page
235 | return render_template('confirm_price.html')
236 | except:
237 | # We haven't started locking in yet, show an error and redirect to the index
238 | session['ErrorMessage'] = "You haven't started the lock in process yet. Please try again."
239 | return redirect(url_for('index'))
240 |
241 |
242 | # Save the auto lock in settings
243 | @app.route('/save_settings', methods=['POST'])
244 | def save_settings():
245 | # If we have sent the form
246 | if request.method == 'POST':
247 | # If we want to auto lock in, set it to true
248 | if(request.form.getlist('auto_lockin')):
249 | config.set('General', 'auto_lock_enabled', "True")
250 | config.set('General', 'auto_lock_fuel_type', request.form['fueltype'])
251 | session['auto_lock'] = True
252 |
253 | # Set the max price to what the user wants as long as it's above 80 and below 2 dollars
254 | if (float(request.form['max_price']) > 80 and float(request.form['max_price']) < 200):
255 | config.set('General', 'max_price', request.form['max_price'])
256 | else:
257 | session['ErrorMessage'] = "The price you tried to lock in was either too cheap or too expensive. It should be between 80 cents and 2 dollars"
258 | return redirect(url_for('index'))
259 |
260 | else:
261 | config.set('General', 'auto_lock_enabled', "False")
262 | session['auto_lock'] = False
263 |
264 |
265 | # Save the config file
266 | with open('./autolock.ini', 'w') as configfile:
267 | config.write(configfile)
268 |
269 | session['SuccessMessage'] = "Settings saved succesfully."
270 | return redirect(url_for('index'))
271 |
272 |
273 |
274 |
275 | @app.route('/lockin', methods=['POST', 'GET'])
276 | def lockin():
277 | if request.method == 'POST':
278 | # Variable used to search for a manual price
279 | priceOveride = False
280 | # Get the form submission method
281 | submissionMethod = request.form['submit']
282 |
283 | # If we didn't try to confirm a manual price
284 | if(submissionMethod != "confirm_price"):
285 |
286 | # Get the fuel type we want
287 | fuelType = str(request.form['fueltype'])
288 | session['fuelType'] = fuelType
289 |
290 | # Clear previous messages
291 | session.pop('ErrorMessage', None)
292 | session.pop('SuccessMessage', None)
293 |
294 | # Get the postcode and price of the cheapest fuel
295 | locationResult = functions.cheapestFuel(fuelType)
296 |
297 | # They tried to do something different from the manual and automatic form, so throw up an error
298 | if(submissionMethod != "manual" and submissionMethod != "automatic"):
299 | session['ErrorMessage'] = "Invalid form submission. Either use the manual or automatic one on the main page."
300 | return redirect(url_for('index'))
301 |
302 | # If they have manually chosen a postcode/suburb set the price overide to true
303 | if(submissionMethod == "manual"):
304 | postcode = str(request.form['postcode'])
305 | priceOveride = True
306 | # Get the latitude and longitude from the store
307 | storeLatLng = functions.getStoreAddress(postcode)
308 | # If we have a match, set the coordinates. If we don't, use Google Maps
309 | if (storeLatLng):
310 | locLat = float(storeLatLng[0])
311 | locLat += (random.uniform(0.01,0.000001) * random.choice([-1,1]))
312 |
313 | locLong = float(storeLatLng[1])
314 | locLong += (random.uniform(0.01,0.000001) * random.choice([-1,1]))
315 | else:
316 | # If we have entered the wrong manual postcode for a store, and haven't
317 | # set the Google Maps API, return an error since we cant use the API
318 | if not custom_coords:
319 | # If it is, get the error message and return back to the index
320 | session['ErrorMessage'] = "Error: You entered a manual postcode where no 7-Eleven store is. Please set a Google Maps API key or enter a valid postcode."
321 | return redirect(url_for('index'))
322 | # Initiate the Google Maps API
323 | gmaps = googlemaps.Client(key = API_KEY)
324 | # Get the longitude and latitude from the submitted postcode
325 | geocode_result = gmaps.geocode(str(request.form['postcode']) + ', Australia')
326 | locLat = geocode_result[0]['geometry']['location']['lat']
327 | locLong = geocode_result[0]['geometry']['location']['lng']
328 | else:
329 | # It was an automatic submission so we will now get the coordinates of the store
330 | # and add a random value to it so we don't appear to lock in from the service station
331 | locLat = locationResult[2]
332 | locLat += (random.uniform(0.01,0.000001) * random.choice([-1,1]))
333 |
334 | locLong = locationResult[3]
335 | locLong += (random.uniform(0.01,0.000001) * random.choice([-1,1]))
336 |
337 | # The payload to start the lock in process.
338 | payload = '{"LastStoreUpdateTimestamp":' + str(int(time.time())) + ',"Latitude":"' + str(locLat) + '","Longitude":"' + str(locLong) + '"}'
339 | tssa = functions.generateTssa(functions.BASE_URL + "FuelLock/StartSession", "POST", payload, session['accessToken'])
340 |
341 | # Now we start the request header
342 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
343 | 'Authorization':'%s' % tssa,
344 | 'X-OsVersion':functions.OS_VERSION,
345 | 'X-OsName':'Android',
346 | 'X-DeviceID':session['DEVICE_ID'],
347 | 'X-VmobID':functions.des_encrypt_string(session['DEVICE_ID']),
348 | 'X-AppVersion':functions.APP_VERSION,
349 | 'X-DeviceSecret':session['deviceSecret'],
350 | 'Content-Type':'application/json; charset=utf-8'}
351 |
352 | # Send the request
353 | response = requests.post(functions.BASE_URL + "FuelLock/StartSession", data=payload, headers=headers)
354 |
355 | # Get the response content so we can check the fuel price
356 | returnContent = response.content
357 |
358 | # Move the response json into an array so we can read it
359 | returnContent = json.loads(returnContent)
360 |
361 | # If there is a fuel lock already in place we get an error!
362 | try:
363 | if returnContent['ErrorType'] == 0:
364 | session['ErrorMessage'] = "An error has occured. This is most likely due to a fuel lock already being in place."
365 | return redirect(url_for('index'))
366 | except:
367 | pass
368 |
369 | # Get the fuel price of all the types of fuel
370 | for each in returnContent['CheapestFuelTypeStores']:
371 | x = each['FuelPrices']
372 | for i in x:
373 | if(str(i['Ean']) == fuelType):
374 | LockinPrice = i['Price']
375 | session['LockinPrice'] = LockinPrice
376 |
377 | # If we have performed an automatic search we run the lowest price check
378 | # LockinPrice = the price from the 7/11 website
379 | # locationResult[1] = the price from the master131 script
380 | # If the price that we tried to lock in is more expensive than scripts price, we return an error
381 | if not(priceOveride):
382 | if not(float(LockinPrice) <= float(locationResult[1])):
383 | session['ErrorMessage'] = "The fuel price is too high compared to the cheapest available. The cheapest we found was at " + locationResult[0] + ". Try locking in there!"
384 | return redirect(url_for('index'))
385 |
386 | if(priceOveride):
387 | return redirect(url_for('confirm'))
388 |
389 | # Now we want to lock in the maximum litres we can.
390 | NumberOfLitres = int(150)
391 |
392 | # Lets start the actual lock in process
393 | payload = '{"AccountId":"' + session['accountID'] + '","FuelType":"' + session['fuelType'] + '","NumberOfLitres":"' + str(NumberOfLitres) + '"}'
394 |
395 | tssa = functions.generateTssa(functions.BASE_URL + "FuelLock/Confirm", "POST", payload, session['accessToken'])
396 |
397 | headers = {'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)',
398 | 'Authorization':'%s' % tssa,
399 | 'X-OsVersion':functions.OS_VERSION,
400 | 'X-OsName':'Android',
401 | 'X-DeviceID':session['DEVICE_ID'],
402 | 'X-VmobID':functions.des_encrypt_string(session['DEVICE_ID']),
403 | 'X-AppVersion':functions.APP_VERSION,
404 | 'X-DeviceSecret':session['deviceSecret'],
405 | 'Content-Type':'application/json; charset=utf-8'}
406 |
407 | # Send through the request and get the response
408 | response = requests.post(functions.BASE_URL + "FuelLock/Confirm", data=payload, headers=headers)
409 |
410 | # Get the response into a json array
411 | returnContent = json.loads(response.content)
412 | try:
413 | # Check if the response was an error message
414 | if(returnContent['Message']):
415 | # If it is, get the error message and return back to the index
416 | session['ErrorMessage'] = returnContent['Message']
417 | return redirect(url_for('index'))
418 | # Otherwise we most likely locked in the price!
419 | if(returnContent['Status'] == "0"):
420 | # Update the fuel prices that are locked in
421 | functions.lockedPrices()
422 | # Get amoount of litres that was locked in from the returned JSON array
423 | session['TotalLitres'] = returnContent['TotalLitres']
424 | session['SuccessMessage'] = "The price was locked in for " + str(session['LockinPrice']) + " cents per litre"
425 |
426 | # Pop our fueltype and lock in price variables
427 | session.pop('fuelType', None)
428 | session.pop('LockinPrice', None)
429 | return redirect(url_for('index'))
430 |
431 | # For whatever reason it saved our lock in anyway and return to the index page
432 | except:
433 | # Update the fuel prices that are locked in
434 | functions.lockedPrices()
435 | session['SuccessMessage'] = "The price was locked in for " + str(session['LockinPrice']) + " cents per litre"
436 | # Get amoount of litres that was locked in from the returned JSON array
437 | session['TotalLitres'] = returnContent['TotalLitres']
438 |
439 | # Pop our fueltype and lock in price variables
440 | session.pop('fuelType', None)
441 | session.pop('LockinPrice', None)
442 | return redirect(url_for('index'))
443 | else:
444 | # They just tried to load the lock in page without sending any data
445 | session['ErrorMessage'] = "Unknown error occured. Please try again!"
446 | return redirect(url_for('index'))
447 |
448 | if __name__ == '__main__':
449 | # Try and open stores.json
450 | if(os.path.isfile('./stores.json')):
451 | with open('./stores.json', 'r') as f:
452 | try:
453 | print("Note: Opening stores.json")
454 | stores = json.load(f)
455 | except:
456 | pass
457 | try:
458 | # Check to see if the stores.json file is older than 1 week.
459 | # If it is, we will download a new version
460 | if(stores['AsOfDate'] < (time.time() - (60 * 60 * 24 * 7))):
461 | print("Note: Your stores.json file is too old, updating it..")
462 | with open('./stores.json', 'wb') as f:
463 | f.write(functions.getStores())
464 |
465 | print("Note: Updating stores.json complete")
466 | except:
467 | # Our json file isn't what we expected, so we will download a new one.
468 | with open('./stores.json', 'wb') as f:
469 | f.write(functions.getStores())
470 |
471 | else:
472 | # We have no stores.json file, so we wil download it
473 | print("Note: No stores.json found, creating it for you.")
474 | with open('./stores.json', 'wb') as f:
475 | f.write(functions.getStores())
476 |
477 | # Check if the autolock.ini file exists, if it doesn't create it.
478 | if not (os.path.exists("./autolock.ini")):
479 | autolocker.create_ini()
480 |
481 | # Open the config file and read the settings
482 | config = configparser.ConfigParser()
483 | config.read("./autolock.ini")
484 |
485 | # Start the autosearch scheduler
486 | if(functions.TZ in [None,""]):
487 | scheduler = BackgroundScheduler(timezone='UTC')
488 | else:
489 | scheduler = BackgroundScheduler(timezone=functions.TZ)
490 | # Start the price search thread and run it every 30 minutes
491 | scheduler.add_job(autolocker.start_lockin, 'interval', seconds=1800)
492 | scheduler.start()
493 |
494 | app.secret_key = os.urandom(12)
495 | app.run(host='0.0.0.0')
496 |
497 | # Uncomment to enable HTTPS/SSL and comment out the line above
498 | #app.run(host='0.0.0.0',port=443,ssl_context=context)
499 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------