def get_shipper(self, shipper_id): query = "SELECT * FROM shippers WHERE shipper_id = %s" val = (shipper_id, ) self.cursor.execute(query, val) for shippers in self.cursor: shipper = Shipper(shippers[0], shippers[1], shippers[2], shippers[3], shippers[4], shippers[5]) self.shippers_list.append(shipper) return shipper
def get_shippers(self): query = ("SELECT * FROM shippers ORDER BY name ASC") self.cursor.execute(query) self.shippers_list = [] for shippers in self.cursor: shipper = Shipper(shippers[0], shippers[1], shippers[2], shippers[3], shippers[4], shippers[5]) self.shippers_list.append(shipper) return self.shippers_list
def save(self, *args, **kwargs): dest = {'city': self.to_location.city, 'region': self.to_location.region, 'country_code': self.to_location.country_code, 'postal_code': self.to_location.postalcode_set.all()[0].code } if self.from_location.city == self.to_location.city: self.type=settings.SHIPPING_OPTIONS[0][0] self.price = settings.GIZMOBOOKS_SHIPPING_PRICE else: self.type=settings.SHIPPING_OPTIONS[1][0] try: product = self.item shipping_calculator = Shipper(dest=dest, product=self.item, service_type=settings.SHIPPING_OPTIONS[1]) shipping_calculator.calculate() self.price = shipping_calculator.cost() except: self.price = Decimal(settings.DEFAULT_SHIPPING_COST) super(Shipping, self).save(*args, **kwargs)
#!/usr/bin/env python import os from shipper import Shipper, run, command import subprocess # DOCKER_URL = "/var/run/docker.sock" DOCKER_HOST = "localhost:4243" DOCKER_URL = "tcp://127.0.0.1:4243" s = Shipper([DOCKER_HOST]) def pmk(t): rootdir = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) return os.path.join(rootdir, t) def splitimage(name): return name.split(':', 1) @command def cleanup_containers(): try: subprocess.check_call( "docker -H {} ps -a -q | grep -q ''".format(DOCKER_URL), shell=True) except subprocess.CalledProcessError, e: s.log.debug("No docker containers found, skipping cleanup") else: cmd = "docker -H={} rm `docker -H {} ps -a -q`".format(
def stop_container(image=None): s = Shipper() s.stop(*s.containers(image=image, running=True))
def start_container(image, command, ports=None): s = Shipper() s.run(image, command, ports=ports, once=True)
def build_container(tag, path): s = Shipper() s.build(tag=tag, path=path)
def get_methods(): return [Shipper()]