This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_valid_mac_address(mac_address): | |
mac_address = mac_address.replace("-", "") | |
if len(mac_address) != 12: | |
raise InvalidMacAddressStringException("The String of the MAC-Address does not contain enough characters") | |
if not all(c in string.hexdigits for c in mac_address): | |
wrong_chars = "" | |
for c in mac_address: | |
if c not in string.hexdigits: | |
wrong_chars += "#%s#" % c | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snmpwalk_mac_file = open("ndms/snmp-results/snmpwalk_mac_adresses.txt", "w") | |
snmpwalk_mac_file.close() | |
snmpwalk_mac_file = open("ndms/snmp-results/snmpwalk_mac_adresses.txt", "w") | |
pickle.dump(mac_objects, snmpwalk_mac_file) | |
#snmpwalk_mac_file = open("ndms/snmp-results/snmpwalk_mac_adresses.txt", "r") | |
#snmp_mac_list = pickle.load(snmpwalk_mac_file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tastypie.exceptions import NotFound | |
from tastypie.resources import ModelResource | |
from tastypie.authentication import BasicAuthentication, ApiKeyAuthentication | |
from tastypie.models import ApiKey | |
from django.contrib.auth.models import User | |
__author__ = 'martinsandstrom' | |
class ApiTokenResource(ModelResource): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tastypie import fields | |
from tastypie.authentication import Authentication | |
from tastypie.authorization import Authorization | |
from tastypie.bundle import Bundle | |
from tastypie.exceptions import NotFound | |
from tastypie.resources import Resource | |
# a dummy class representing a row of data | |
class Row(object): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.datetime + datetime.timedelta(days=3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ reservation.datetime|date:'Y-m-d\TH:i:s' }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def product_list(self): | |
products = self.products.all() | |
product_list = [] | |
for product in products: | |
for product_store in product.stores_for_product.all(): | |
product_list.append(product_store) | |
for cat in self.child_categories.all(): | |
for product in cat.product_list(): | |
product_list.append(product) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf "username:$(openssl passwd -crypt password)\n" >> htpasswd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rgb_to_cmyk(r,g,b): | |
cmyk_scale = 100 | |
if (r == 0) and (g == 0) and (b == 0): | |
# black | |
return 0, 0, 0, cmyk_scale | |
# rgb [0,255] -> cmy [0,1] | |
c = 1 - r / 255. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tastypie import fields | |
from tastypie.authentication import Authentication | |
from tastypie.authorization import Authorization | |
from tastypie.bundle import Bundle | |
from tastypie.exceptions import NotFound | |
from tastypie.resources import Resource | |
# a dummy class representing a row of data | |
class Row(object): |