| Line 10... |
Line 10... |
| 10 |
sys.path.insert(0, os.getcwd())
|
10 |
sys.path.insert(0, os.getcwd())
|
| 11 |
|
11 |
|
| 12 |
from shop2020.logistics.service.impl import DataService
|
12 |
from shop2020.logistics.service.impl import DataService
|
| 13 |
from shop2020.logistics.service.impl.DataService import Awb, Provider
|
13 |
from shop2020.logistics.service.impl.DataService import Awb, Provider
|
| 14 |
|
14 |
|
| 15 |
def load_awb_numbers(filename, provider_id, type):
|
15 |
def load_awb_numbers(filename, provider_id, type, db_hostname):
|
| 16 |
DataService.initialize('logistics')
|
16 |
DataService.initialize(dbname='logistics', db_hostname=db_hostname)
|
| 17 |
|
17 |
|
| 18 |
provider = Provider.get_by(id=provider_id)
|
18 |
provider = Provider.get_by(id=provider_id)
|
| 19 |
if provider is None:
|
19 |
if provider is None:
|
| 20 |
exit()
|
20 |
exit()
|
| 21 |
|
21 |
|
| Line 41... |
Line 41... |
| 41 |
type="int", help="Load these entries for PROVIDER",
|
41 |
type="int", help="Load these entries for PROVIDER",
|
| 42 |
metavar="PROVIDER")
|
42 |
metavar="PROVIDER")
|
| 43 |
parser.add_option("-t", "--type", dest="type",
|
43 |
parser.add_option("-t", "--type", dest="type",
|
| 44 |
type="string", help="The TYPE of orders these AWB numbers are for",
|
44 |
type="string", help="The TYPE of orders these AWB numbers are for",
|
| 45 |
metavar="TYPE")
|
45 |
metavar="TYPE")
|
| - |
|
46 |
parser.add_option("-H", "--host", dest="hostname",
|
| - |
|
47 |
default="localhost",
|
| - |
|
48 |
type="string", help="The HOST where the DB server is running",
|
| - |
|
49 |
metavar="HOST")
|
| 46 |
(options, args) = parser.parse_args()
|
50 |
(options, args) = parser.parse_args()
|
| 47 |
if len(args) != 0:
|
51 |
if len(args) != 0:
|
| 48 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
52 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
| 49 |
filename = options.filename
|
53 |
filename = options.filename
|
| 50 |
provider_id = options.provider_id
|
54 |
provider_id = options.provider_id
|
| 51 |
type = options.type
|
55 |
type = options.type
|
| 52 |
if filename is None or provider_id is None or type is None:
|
56 |
if filename is None or provider_id is None or type is None:
|
| 53 |
parser.error("A provider's name and a filename must be provided. Use -h for usage details.")
|
57 |
parser.error("A provider's name and a filename must be provided. Use -h for usage details.")
|
| 54 |
load_awb_numbers(filename, provider_id, type)
|
58 |
load_awb_numbers(filename, provider_id, type, options.hostname)
|
| 55 |
|
59 |
|
| 56 |
if __name__ == '__main__':
|
60 |
if __name__ == '__main__':
|
| 57 |
main()
|
61 |
main()
|