| Line 12... |
Line 12... |
| 12 |
from shop2020.logistics.service.impl import DataService
|
12 |
from shop2020.logistics.service.impl import DataService
|
| 13 |
from shop2020.logistics.service.impl.DataService import Provider,\
|
13 |
from shop2020.logistics.service.impl.DataService import Provider,\
|
| 14 |
ServiceableLocationDetails, DeliveryEstimate
|
14 |
ServiceableLocationDetails, DeliveryEstimate
|
| 15 |
from shop2020.thriftpy.logistics.ttypes import StationType, WarehouseLocation
|
15 |
from shop2020.thriftpy.logistics.ttypes import StationType, WarehouseLocation
|
| 16 |
|
16 |
|
| 17 |
def load_service_details(filename, provider_name):
|
17 |
def load_service_details(filename, provider_name, db_hostname):
|
| 18 |
DataService.initialize('logistics')
|
18 |
DataService.initialize(dbname='logistics', db_hostname=db_hostname)
|
| 19 |
|
19 |
|
| 20 |
#provider_name = provider_name.lower()
|
20 |
#provider_name = provider_name.lower()
|
| 21 |
provider = Provider.get_by(name=provider_name)
|
21 |
provider = Provider.get_by(name=provider_name)
|
| 22 |
if provider is None:
|
22 |
if provider is None:
|
| 23 |
provider = Provider()
|
23 |
provider = Provider()
|
| Line 63... |
Line 63... |
| 63 |
help="Read the serviceable location list from FILE",
|
63 |
help="Read the serviceable location list from FILE",
|
| 64 |
metavar="FILE")
|
64 |
metavar="FILE")
|
| 65 |
parser.add_option("-P", "--provider", dest="provider_name",
|
65 |
parser.add_option("-P", "--provider", dest="provider_name",
|
| 66 |
type="string", help="Create these entries for PROVIDER",
|
66 |
type="string", help="Create these entries for PROVIDER",
|
| 67 |
metavar="PROVIDER")
|
67 |
metavar="PROVIDER")
|
| - |
|
68 |
parser.add_option("-H", "--host", dest="hostname",
|
| - |
|
69 |
default="localhost",
|
| - |
|
70 |
type="string", help="The HOST where the DB server is running",
|
| - |
|
71 |
metavar="HOST")
|
| 68 |
(options, args) = parser.parse_args()
|
72 |
(options, args) = parser.parse_args()
|
| 69 |
if len(args) != 0:
|
73 |
if len(args) != 0:
|
| 70 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
74 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
| 71 |
filename = options.filename
|
75 |
filename = options.filename
|
| 72 |
provider_name = options.provider_name
|
76 |
provider_name = options.provider_name
|
| 73 |
if filename is None or provider_name is None:
|
77 |
if filename is None or provider_name is None:
|
| 74 |
parser.error("A provider's name and a filename must be provided. Use -h for more details.")
|
78 |
parser.error("A provider's name and a filename must be provided. Use -h for more details.")
|
| 75 |
load_service_details(filename, provider_name)
|
79 |
load_service_details(filename, provider_name, options.hostname)
|
| 76 |
|
80 |
|
| 77 |
if __name__ == '__main__':
|
81 |
if __name__ == '__main__':
|
| 78 |
main()
|
82 |
main()
|
| 79 |
|
83 |
|