File packages/gui/category_chooser.py added (mode: 100644) (index 0000000..55156e0) |
|
1 |
|
import tkinter |
|
2 |
|
import tkinter.filedialog |
|
3 |
|
|
|
4 |
|
class DropdownChooser(tkinter.Frame): |
|
5 |
|
def __init__(self, master, *args, **kwargs): |
|
6 |
|
tkinter.Frame.__init__(self, master, *args, **kwargs) |
|
7 |
|
self.master = master |
|
8 |
|
self.args = args |
|
9 |
|
self.kwargs = kwargs |
|
10 |
|
self.initialize() |
|
11 |
|
|
|
12 |
|
def initialize(self): |
|
13 |
|
self.grid() |
|
14 |
|
|
|
15 |
|
self.optionvar = tkinter.StringVar(self) |
|
16 |
|
|
|
17 |
|
self.options = {'Men.Aladinhose':'34', |
|
18 |
|
'Men.Sommerhose':'36', |
|
19 |
|
'Men.Stoffhose':'35', |
|
20 |
|
'Men.Fischerhose':'85', |
|
21 |
|
'Men.Hemden': '38', |
|
22 |
|
'Men.Jacken' :'41', |
|
23 |
|
'Men.Hoodie' : '40', |
|
24 |
|
'Men.Tshirt' :'39', |
|
25 |
|
'Women.Kleid' :'62', |
|
26 |
|
'Women.Skirt' :'87', |
|
27 |
|
'Women.Sarong-K' :'64', |
|
28 |
|
'Women.Tunika' :'63', |
|
29 |
|
'Women.Top' :'65', |
|
30 |
|
'Women.Jacken' :'84', |
|
31 |
|
'Women.Sarong-O' :'69', |
|
32 |
|
'Women.Hoodie' :'68', |
|
33 |
|
'Women.Tshirt' :'66', |
|
34 |
|
'Women.Aladinhose' :'53', |
|
35 |
|
'Women.Fischerhose' :'96', |
|
36 |
|
'Women.Legging' :'73', |
|
37 |
|
'Women.Hosenrock' :'72', |
|
38 |
|
'Women.Sommerhose' :'71', |
|
39 |
|
'Women.Stoffhose' :'70', |
|
40 |
|
'Acce.Men.Patch' :'80', |
|
41 |
|
'Acce.Men.Halstuch' :'91', |
|
42 |
|
'Acce.Men.Sarong' :'89', |
|
43 |
|
'Acce.Men.Suncatcher' :'83', |
|
44 |
|
'Acce.Men.Kissen' :'82', |
|
45 |
|
'Acce.Men.Airbrush' :'81', |
|
46 |
|
'Acce.Women.Patch' :'76', |
|
47 |
|
'Acce.Women.Halstuch' :'90', |
|
48 |
|
'Acce.Women.Sarong' :'88', |
|
49 |
|
'Acce.Women.Suncatcher' :'79', |
|
50 |
|
'Acce.Women.Kissen' :'78', |
|
51 |
|
'Acce.Women.Airbrush' :'77', |
|
52 |
|
'Bags.Men.Schultertasche' :'58', |
|
53 |
|
'Bags.Men.Rucksack' :'59', |
|
54 |
|
'Bags.Women.Schultertasche' :'60', |
|
55 |
|
'Bags.Women.Rucksack':'61'} |
|
56 |
|
|
|
57 |
|
self.optionvar.set('pants') |
|
58 |
|
|
|
59 |
|
self.dropdown_menu = tkinter.OptionMenu(self, self.optionvar, *[ *self.options ]) |
|
60 |
|
self.dropdown_menu.grid(row=0, column=0, sticky="EW") |
|
61 |
|
|
|
62 |
|
self.optionvar.trace('w', self.change_dropdown) |
|
63 |
|
|
|
64 |
|
# Create a textbox to show the result of the choosing |
|
65 |
|
self.resultbox = tkinter.Entry(self, width=50, bg="white") |
|
66 |
|
self.resultbox.grid(row=1, column=0, columnspan=2, sticky="EW") |
|
67 |
|
|
|
68 |
|
def change_dropdown(self, *args): |
|
69 |
|
if( not( self.resultbox.get() ) ): |
|
70 |
|
self. resultbox.insert(tkinter.INSERT, self.options[ self.optionvar.get() ] ) |
|
71 |
|
else: |
|
72 |
|
self.resultbox.insert(tkinter.INSERT, ', ' + self.options[ self.optionvar.get() ] ) |
|
73 |
|
|
|
74 |
|
|
|
75 |
|
class DescBox(tkinter.Frame): |
|
76 |
|
def __init__(self, master, desctext): |
|
77 |
|
tkinter.Frame.__init__(self, master) |
|
78 |
|
self.master = master |
|
79 |
|
self.desctext = desctext |
|
80 |
|
self.initialize() |
|
81 |
|
|
|
82 |
|
def initialize(self): |
|
83 |
|
self.grid() |
|
84 |
|
|
|
85 |
|
self.desc_label = tkinter.Label(self, text=self.desctext) |
|
86 |
|
self.desc_label.grid(rowspan=2,column=1, sticky="EW") |
|
87 |
|
|
|
88 |
|
|
|
89 |
|
class CategoryChooser(tkinter.Tk): |
|
90 |
|
def __init__(self, master, upath=''): |
|
91 |
|
tkinter.Tk.__init__(self, master) |
|
92 |
|
self.master = master |
|
93 |
|
self.upath = upath |
|
94 |
|
self.newpath = '' |
|
95 |
|
self.data = {'name':'', 'categories':''} |
|
96 |
|
self.initialize() |
|
97 |
|
self.protocol("WM_WINDOW_DELETE", self.close_app) |
|
98 |
|
|
|
99 |
|
def initialize(self): |
|
100 |
|
self.grid() |
|
101 |
|
|
|
102 |
|
self.pathdesc = DescBox(master=self, desctext="The current Upload path is: \n" + self.upath) |
|
103 |
|
self.pathdesc.grid(row=0, columnspan=2, pady=10, padx=10) |
|
104 |
|
|
|
105 |
|
self.changepathbutton = tkinter.Button(self, text="Choose a new path", command=lambda: self.get_new_path()) |
|
106 |
|
self.changepathbutton.grid(row=1, column=1, pady=10, padx=10) |
|
107 |
|
|
|
108 |
|
self.dropdesc = DescBox(master=self, desctext="Choose the categories for the product.") |
|
109 |
|
self.dropdesc.grid(row=2, columnspan=2, pady=10, padx=10) |
|
110 |
|
|
|
111 |
|
self.dropdown = DropdownChooser(master=self) |
|
112 |
|
self.dropdown.grid(row=3, column=1) |
|
113 |
|
|
|
114 |
|
self.namedesc = DescBox(master=self, desctext="Choose a name for the product") |
|
115 |
|
self.namedesc.grid(row=4, columnspan=2, pady=10, padx=10) |
|
116 |
|
|
|
117 |
|
self.namechooser = tkinter.Entry(self, width=50, bg="white") |
|
118 |
|
self.namechooser.grid(row=5, columnspan=2, pady=10, padx=10) |
|
119 |
|
|
|
120 |
|
self.accept = tkinter.Button(self, text="Accept", |
|
121 |
|
command=lambda: self.get_input(self.dropdown.resultbox.get(), self.namechooser.get())) |
|
122 |
|
self.accept.grid(row=6, column=2, pady=10, padx=10) |
|
123 |
|
|
|
124 |
|
def get_input(self, categories, name): |
|
125 |
|
self.data['name'] = name |
|
126 |
|
self.data['categories'] = categories |
|
127 |
|
# Close the gui after accepting the input to stop the mainloop |
|
128 |
|
self.close_app() |
|
129 |
|
|
|
130 |
|
def get_new_path(self): |
|
131 |
|
print("Get the new path of the upload folder.") |
|
132 |
|
self.newpath = tkinter.filedialog.askdirectory() |
|
133 |
|
|
|
134 |
|
def close_app(self): |
|
135 |
|
self.withdraw() |
|
136 |
|
|
File packages/variation_upload.py changed (mode: 100644) (index e41d0f2..6629c04) |
... |
... |
def writeCSV(dataobject, name, columns, upload_path): |
39 |
39 |
output_path = upload_path + output_name |
output_path = upload_path + output_name |
40 |
40 |
|
|
41 |
41 |
with open(output_path, mode='a') as item: |
with open(output_path, mode='a') as item: |
42 |
|
writer = csv.DictWriter(item, delimiter=";", fieldnames=columns) |
|
|
42 |
|
writer = csv.DictWriter(item, delimiter=";", fieldnames=columns, lineterminator='\n') |
43 |
43 |
writer.writeheader() |
writer.writeheader() |
44 |
44 |
for row in dataobject: |
for row in dataobject: |
45 |
45 |
writer.writerow(dataobject[row]) |
writer.writerow(dataobject[row]) |
|
... |
... |
def variationUpload(flatfile, intern_number, folder): |
65 |
65 |
Data = SortedDict() |
Data = SortedDict() |
66 |
66 |
item_name = '' |
item_name = '' |
67 |
67 |
|
|
68 |
|
with open(flatfile, mode='r') as item: |
|
|
68 |
|
with open(flatfile['path'], mode='r', encoding=flatfile['encoding']) as item: |
69 |
69 |
reader = csv.DictReader(item, delimiter=";") |
reader = csv.DictReader(item, delimiter=";") |
70 |
70 |
for row in reader: |
for row in reader: |
71 |
71 |
if(row['parent_child'] == 'child'): |
if(row['parent_child'] == 'child'): |
|
... |
... |
def variationUpload(flatfile, intern_number, folder): |
119 |
119 |
|
|
120 |
120 |
# open the intern numbers csv and fill in the remaining missing fields by using the |
# open the intern numbers csv and fill in the remaining missing fields by using the |
121 |
121 |
# item_sku as dict key |
# item_sku as dict key |
122 |
|
with open(intern_number, mode='r') as item: |
|
|
122 |
|
with open(intern_number['path'], mode='r', encoding=intern_number['encoding']) as item: |
123 |
123 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
124 |
124 |
for row in reader: |
for row in reader: |
125 |
125 |
# check if the sku is within the keys of the Data Dictionary |
# check if the sku is within the keys of the Data Dictionary |
|
... |
... |
def setActive(flatfile, export, folder): |
140 |
140 |
column_names = ['Active', 'VariationID'] |
column_names = ['Active', 'VariationID'] |
141 |
141 |
Data = {} |
Data = {} |
142 |
142 |
# open the flatfile to get the sku names |
# open the flatfile to get the sku names |
143 |
|
with open(flatfile, mode='r') as item: |
|
|
143 |
|
with open(flatfile['path'], mode='r', encoding=flatfile['encoding']) as item: |
144 |
144 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
145 |
145 |
|
|
146 |
146 |
for row in reader: |
for row in reader: |
147 |
147 |
values = ['Y', ''] |
values = ['Y', ''] |
148 |
148 |
Data[row['item_sku']] = dict(zip(column_names, values)) |
Data[row['item_sku']] = dict(zip(column_names, values)) |
149 |
149 |
|
|
150 |
|
with open(export, mode='r') as item: |
|
|
150 |
|
with open(export['path'], mode='r', encoding=export['encoding']) as item: |
151 |
151 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
152 |
152 |
wrong_delimiter = False |
wrong_delimiter = False |
153 |
153 |
|
|
|
... |
... |
def EANUpload(flatfile, export, stocklist, folder): |
178 |
178 |
barcode_types = {'EAN' : {'id' : 1, 'name' : 'EAN', 'type' : 'GTIN_13'}, |
barcode_types = {'EAN' : {'id' : 1, 'name' : 'EAN', 'type' : 'GTIN_13'}, |
179 |
179 |
'FNSKU' : {'id' : 5, 'name' : 'FNSKU', 'type' : 'EAN_13'}} |
'FNSKU' : {'id' : 5, 'name' : 'FNSKU', 'type' : 'EAN_13'}} |
180 |
180 |
Data = {} |
Data = {} |
181 |
|
with open(flatfile, mode='r') as item: |
|
|
181 |
|
with open(flatfile['path'], mode='r', encoding=flatfile['encoding']) as item: |
182 |
182 |
reader = csv.DictReader(item, delimiter=";") |
reader = csv.DictReader(item, delimiter=";") |
183 |
183 |
|
|
184 |
184 |
for row in reader: |
for row in reader: |
|
... |
... |
def EANUpload(flatfile, export, stocklist, folder): |
200 |
200 |
Data[row['item_sku'] + barcode] = dict(zip(column_names, values)) |
Data[row['item_sku'] + barcode] = dict(zip(column_names, values)) |
201 |
201 |
|
|
202 |
202 |
# open the exported file to get the variation id |
# open the exported file to get the variation id |
203 |
|
with open(export, mode='r') as item: |
|
|
203 |
|
with open(export['path'], mode='r', encoding=export['encoding']) as item: |
204 |
204 |
reader = csv.DictReader(item, delimiter=";") |
reader = csv.DictReader(item, delimiter=";") |
205 |
205 |
|
|
206 |
206 |
for row in reader: |
for row in reader: |
|
... |
... |
def EANUpload(flatfile, export, stocklist, folder): |
208 |
208 |
if(row['VariationNumber'] + barcode in [*Data]): |
if(row['VariationNumber'] + barcode in [*Data]): |
209 |
209 |
Data[row['VariationNumber'] + barcode]['VariationID'] = row['VariationID'] |
Data[row['VariationNumber'] + barcode]['VariationID'] = row['VariationID'] |
210 |
210 |
|
|
211 |
|
with open(stocklist, mode='r') as item: |
|
|
211 |
|
with open(stocklist['path'], mode='r', encoding=stocklist['encoding']) as item: |
212 |
212 |
reader = csv.DictReader(item, delimiter=";") |
reader = csv.DictReader(item, delimiter=";") |
213 |
213 |
|
|
214 |
214 |
for row in reader: |
for row in reader: |
|
... |
... |
def marketConnection(export, folder, ebay=0, amazon=0, shop=0): |
234 |
234 |
'webApi', 'AmazonFBAGermany', 'AmazonFBA', 'eBayGermany', 'Ebay', 'MandantShop'] |
'webApi', 'AmazonFBAGermany', 'AmazonFBA', 'eBayGermany', 'Ebay', 'MandantShop'] |
235 |
235 |
|
|
236 |
236 |
Data = {} |
Data = {} |
237 |
|
with open(export, mode='r') as item: |
|
|
237 |
|
with open(export['path'], mode='r', encoding=export['encoding']) as item: |
238 |
238 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
239 |
239 |
|
|
240 |
240 |
for row in reader: |
for row in reader: |
|
... |
... |
def numberOfSizes(flatfile): |
253 |
253 |
length_set = 0 |
length_set = 0 |
254 |
254 |
sizeset = set() |
sizeset = set() |
255 |
255 |
|
|
256 |
|
with open(flatfile, mode='r') as item: |
|
|
256 |
|
with open(flatfile['path'], mode='r', encoding=flatfile['encoding']) as item: |
257 |
257 |
reader = csv.DictReader(item, delimiter=';') |
reader = csv.DictReader(item, delimiter=';') |
258 |
258 |
|
|
259 |
259 |
for row in reader: |
for row in reader: |
File product_import.py changed (mode: 100644) (index 59e6159..8641cd7) |
1 |
|
from tkinter import Tk |
|
2 |
|
from tkinter.filedialog import askopenfilename, askdirectory |
|
|
1 |
|
import tkinter |
|
2 |
|
from tkinter.filedialog import askopenfilename |
3 |
3 |
import sys |
import sys |
4 |
4 |
import platform |
import platform |
5 |
5 |
import os |
import os |
6 |
6 |
import ntpath |
import ntpath |
7 |
|
from packages.item_upload import itemUpload, itemPropertyUpload, WrongEncodingException |
|
|
7 |
|
from packages.item_upload import itemUpload, itemPropertyUpload, WrongEncodingException, check_encoding |
8 |
8 |
from packages.variation_upload import variationUpload, setActive, EANUpload, marketConnection, EmptyFieldWarning |
from packages.variation_upload import variationUpload, setActive, EANUpload, marketConnection, EmptyFieldWarning |
9 |
9 |
from packages.stock_upload import priceUpload |
from packages.stock_upload import priceUpload |
10 |
10 |
from packages.amazon_data_upload import amazonSkuUpload, amazonDataUpload, asinUpload, featureUpload |
from packages.amazon_data_upload import amazonSkuUpload, amazonDataUpload, asinUpload, featureUpload |
11 |
11 |
from packages.image_upload import imageUpload |
from packages.image_upload import imageUpload |
12 |
12 |
from packages.log_files import fileNotFoundLog, keyErrorLog, wrongEncodingLog, unboundLocalLog, emptyFieldWarningLog |
from packages.log_files import fileNotFoundLog, keyErrorLog, wrongEncodingLog, unboundLocalLog, emptyFieldWarningLog |
|
13 |
|
from packages.gui.category_chooser import CategoryChooser |
|
14 |
|
from packages.config import config_creation, config_read, config_write |
13 |
15 |
|
|
14 |
16 |
|
|
15 |
17 |
def main(): |
def main(): |
|
... |
... |
def main(): |
18 |
20 |
upload_folder = '' |
upload_folder = '' |
19 |
21 |
log_folder = '' |
log_folder = '' |
20 |
22 |
recent_path = '' |
recent_path = '' |
|
23 |
|
config_path = '' |
|
24 |
|
sheet = {'path':'', 'encoding':''} |
|
25 |
|
intern_number = {'path':'', 'encoding':''} |
|
26 |
|
export = {'path':'', 'encoding':''} |
|
27 |
|
stocklist = {'path':'', 'encoding':''} |
21 |
28 |
step = int(0) |
step = int(0) |
22 |
29 |
fexc = '' |
fexc = '' |
23 |
30 |
# Create a list of step names where every name fits to the index of a step number |
# Create a list of step names where every name fits to the index of a step number |
|
... |
... |
def main(): |
55 |
62 |
'package_height':19, |
'package_height':19, |
56 |
63 |
'package_weight':20 |
'package_weight':20 |
57 |
64 |
} |
} |
58 |
|
#app = UploadGUI(None) |
|
59 |
|
#app.title("Amazon Flatfile to PlentyMarkets Upload") |
|
60 |
|
# app.mainloop() |
|
61 |
|
''' |
|
62 |
|
Command Line Test Version will be used within the GUI as soon as it is finished |
|
63 |
|
''' |
|
64 |
|
root = Tk() |
|
65 |
|
root.withdraw() |
|
66 |
65 |
# Check if the os is Linux, in that case the initial directory is Documents |
# Check if the os is Linux, in that case the initial directory is Documents |
67 |
66 |
# Unless Documents is not available in which case it is ~ |
# Unless Documents is not available in which case it is ~ |
68 |
67 |
initial_directory = '../' |
initial_directory = '../' |
|
... |
... |
def main(): |
73 |
72 |
else: |
else: |
74 |
73 |
initial_directory = '/home/' + os.getlogin() |
initial_directory = '/home/' + os.getlogin() |
75 |
74 |
|
|
|
75 |
|
# Create a config if there is none |
|
76 |
|
config_path = config_creation() |
|
77 |
|
|
|
78 |
|
# Get the Upload and data folder from the config if possible |
|
79 |
|
if(config_read(config_path)['upload_folder']): |
|
80 |
|
upload_folder = config_read(config_path)['upload_folder'] |
|
81 |
|
if(config_read(config_path)['data_folder']): |
|
82 |
|
recent_path = config_read(config_path)['data_folder'] |
|
83 |
|
if(not(recent_path)): |
|
84 |
|
recent_path = tkinter.filedialog.askdirectory(initialdir=initial_directory, |
|
85 |
|
title="Choose a folder from where to upload") |
|
86 |
|
|
|
87 |
|
# Ask the user for input inside a gui asking for categories and name |
|
88 |
|
cchooser = CategoryChooser(None, upload_folder) |
|
89 |
|
cchooser.title("Choose the category and name") |
|
90 |
|
LOOP_ACTIVE = True |
|
91 |
|
while (LOOP_ACTIVE): |
|
92 |
|
if(cchooser): |
|
93 |
|
cchooser.update() |
|
94 |
|
if(cchooser.data['name'] and cchooser.data['categories']): |
|
95 |
|
LOOP_ACTIVE = False |
|
96 |
|
cchooser.destroy() |
|
97 |
|
|
|
98 |
|
user_data = cchooser.data |
|
99 |
|
if(cchooser.newpath): |
|
100 |
|
config_update = {'row1':{ 'title': 'upload_folder', 'path': cchooser.newpath }, |
|
101 |
|
'row2':{ 'title':'data_folder', 'path':recent_path }} |
|
102 |
|
print(config_update) |
|
103 |
|
try: |
|
104 |
|
config_write(config_path, config_update) |
|
105 |
|
except Exception as err: |
|
106 |
|
print("ERROR: {0}\n".format(err)) |
|
107 |
|
upload_folder = cchooser.newpath |
|
108 |
|
|
|
109 |
|
if(user_data): |
|
110 |
|
# Check if there is already a log folder within the upload folder |
|
111 |
|
if( not(os.path.exists(os.path.join(upload_folder, 'log'))) ): |
|
112 |
|
log_folder = os.path.join(upload_folder, 'log') |
|
113 |
|
os.makedirs(log_folder) |
|
114 |
|
elif( os.path.exists(os.path.join(upload_folder, 'log')) ): |
|
115 |
|
log_folder = os.path.join(upload_folder, 'log') |
76 |
116 |
|
|
77 |
|
# Get the upload folder path from the user |
|
78 |
|
upload_folder = askdirectory(initialdir=initial_directory, |
|
79 |
|
title="Choose a folder for the upload files.") |
|
80 |
|
# Check if there is already a log folder within the upload folder |
|
81 |
|
if( not(os.path.exists(os.path.join(upload_folder, 'log'))) ): |
|
82 |
|
log_folder = os.path.join(upload_folder, 'log') |
|
83 |
|
os.makedirs(log_folder) |
|
84 |
|
elif( os.path.exists(os.path.join(upload_folder, 'log')) ): |
|
85 |
|
log_folder = os.path.join(upload_folder, 'log') |
|
86 |
|
|
|
87 |
|
step += 1 |
|
88 |
|
sheet = askopenfilename(initialdir=initial_directory, |
|
89 |
|
title="Amazon Flatfile as .csv", |
|
90 |
|
filetypes=[ ("csv files", "*.csv") ]) |
|
91 |
|
if(sheet): |
|
92 |
|
recent_path = os.path.dirname(sheet) |
|
93 |
|
|
|
94 |
|
step += 1 |
|
95 |
|
intern_number = askopenfilename(initialdir=recent_path, |
|
96 |
|
title="The Intern Numbers as .csv", |
|
97 |
|
filetypes=[ ("csv files", "*.csv") ]) |
|
98 |
|
|
|
99 |
|
print("spreadsheet csv containing the flatfile : ", sheet) |
|
100 |
|
print("spreadsheet csv containing the intern numbers : ", intern_number) |
|
101 |
|
|
|
102 |
|
step += 1 |
|
103 |
|
try: |
|
104 |
|
print("\nItem Upload\n") |
|
105 |
|
itemUpload(sheet, intern_number, upload_folder) |
|
106 |
|
except WrongEncodingException: |
|
107 |
|
wrongEncodingLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name="flatfile") |
|
108 |
|
except KeyError as kexc: |
|
109 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
110 |
|
except OSError as fexc: |
|
111 |
|
fileNotFoundLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name="intern_numbers") |
|
112 |
|
except TypeError: |
|
113 |
|
fileNotFoundLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name="flatfile") |
|
114 |
|
except UnboundLocalError as uexc: |
|
115 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
116 |
|
except EmptyFieldWarning as eexc: |
|
117 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
118 |
|
except Exception as exc: |
|
119 |
|
print("Item Upload failed!\n") |
|
120 |
|
print("Here: ", exc, '\n') |
|
121 |
|
if(exc == 'item_sku'): |
|
122 |
|
print("It is very likely that you don't have the proper headers, use the english ones!\n") |
|
123 |
|
e = sys.exc_info() |
|
124 |
|
for element in e: |
|
125 |
|
print(element) |
|
126 |
|
|
|
127 |
|
step += 1 |
|
128 |
|
try: |
|
129 |
|
print("\nVariation Upload\n") |
|
130 |
|
variationUpload(sheet, intern_number, upload_folder) |
|
131 |
|
except KeyError as kexc: |
|
132 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
133 |
|
except UnboundLocalError as uexc: |
|
134 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
135 |
|
except EmptyFieldWarning as eexc: |
|
136 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
137 |
|
except Exception as exc: |
|
138 |
|
print("VariationUpload failed!\n") |
|
139 |
|
e = sys.exc_info() |
|
140 |
|
for element in e: |
|
141 |
|
print(element) |
|
142 |
|
|
|
143 |
|
print("###########################################################") |
|
144 |
|
print("\nUpload the files in plentymarkets, make sure that the categories are set because they are necessary for the active Upload.\n") |
|
145 |
|
|
|
146 |
|
moveon = input("Continue(ENTER)") |
|
147 |
|
|
|
148 |
|
print("\nGet a dataexport from the plentymarket site from the variation attributes, in order to access the current Variation ID.\n") |
|
149 |
|
|
|
150 |
|
step += 1 |
|
151 |
|
try: |
|
152 |
|
export = askopenfilename(initialdir=recent_path, |
|
153 |
|
title="The Export File from Plentymarkets as .csv", |
|
|
117 |
|
step += 1 |
|
118 |
|
sheet['path'] = askopenfilename(initialdir=recent_path, |
|
119 |
|
title="Amazon Flatfile as .csv", |
154 |
120 |
filetypes=[ ("csv files", "*.csv") ]) |
filetypes=[ ("csv files", "*.csv") ]) |
155 |
|
except OSError as fexc: |
|
156 |
|
fileNotFoundLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name=fexc) |
|
157 |
|
except Exception as exc: |
|
158 |
|
print(exc) |
|
159 |
|
print("Something went wrong at the Export file import!") |
|
160 |
121 |
|
|
161 |
|
print("spreadsheet csv containing the export : ", export) |
|
|
122 |
|
sheet['encoding'] = check_encoding(sheet) |
162 |
123 |
|
|
163 |
|
try: |
|
164 |
|
print("Active, properties , features & price Upload") |
|
165 |
124 |
step += 1 |
step += 1 |
166 |
|
for name in features: |
|
167 |
|
featureUpload(flatfile=sheet, feature=name, feature_id=features[name], folder=upload_folder) |
|
|
125 |
|
intern_number['path'] = askopenfilename(initialdir=recent_path, |
|
126 |
|
title="The Intern Numbers as .csv", |
|
127 |
|
filetypes=[ ("csv files", "*.csv") ]) |
|
128 |
|
|
|
129 |
|
intern_number['encoding'] = check_encoding(intern_number) |
168 |
130 |
|
|
169 |
131 |
step += 1 |
step += 1 |
170 |
|
setActive(sheet, export, upload_folder) |
|
|
132 |
|
try: |
|
133 |
|
print("\nItem Upload\n") |
|
134 |
|
itemUpload(sheet, intern_number, upload_folder) |
|
135 |
|
except WrongEncodingException: |
|
136 |
|
wrongEncodingLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name="flatfile") |
|
137 |
|
except KeyError as kexc: |
|
138 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
139 |
|
except OSError as fexc: |
|
140 |
|
fileNotFoundLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name="intern_numbers") |
|
141 |
|
except TypeError: |
|
142 |
|
fileNotFoundLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name="flatfile") |
|
143 |
|
except UnboundLocalError as uexc: |
|
144 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
145 |
|
except EmptyFieldWarning as eexc: |
|
146 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
147 |
|
except Exception as exc: |
|
148 |
|
print("Item Upload failed!\n") |
|
149 |
|
print("Here: ", exc, '\n') |
|
150 |
|
if(exc == 'item_sku'): |
|
151 |
|
print("It is very likely that you don't have the proper headers, use the english ones!\n") |
|
152 |
|
e = sys.exc_info() |
|
153 |
|
for element in e: |
|
154 |
|
print(element) |
|
155 |
|
|
171 |
156 |
step += 1 |
step += 1 |
172 |
|
itemPropertyUpload(sheet, export, upload_folder) |
|
|
157 |
|
try: |
|
158 |
|
print("\nVariation Upload\n") |
|
159 |
|
variationUpload(sheet, intern_number, upload_folder) |
|
160 |
|
except KeyError as kexc: |
|
161 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
162 |
|
except UnboundLocalError as uexc: |
|
163 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
164 |
|
except EmptyFieldWarning as eexc: |
|
165 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
166 |
|
except Exception as exc: |
|
167 |
|
print("VariationUpload failed!\n") |
|
168 |
|
e = sys.exc_info() |
|
169 |
|
for element in e: |
|
170 |
|
print(element) |
|
171 |
|
|
|
172 |
|
print("###########################################################") |
|
173 |
|
print("\nUpload the files in plentymarkets, make sure that the categories are set because they are necessary for the active Upload.\n") |
|
174 |
|
|
|
175 |
|
print('press ENTER to continue') |
|
176 |
|
input() |
|
177 |
|
|
|
178 |
|
print("\nGet a dataexport from the plentymarket site from the variation attributes, in order to access the current Variation ID.\n") |
|
179 |
|
|
173 |
180 |
step += 1 |
step += 1 |
174 |
|
priceUpload(sheet, export, upload_folder) |
|
175 |
|
except KeyError as kexc: |
|
176 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
177 |
|
except UnboundLocalError as uexc: |
|
178 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
179 |
|
except EmptyFieldWarning as eexc: |
|
180 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
181 |
|
except OSError as err: |
|
182 |
|
print(err) |
|
183 |
|
print("Missing Data, check if you have\n - a flatfile\n - a intern file table\n - export file from plentymarkets\n - a sheet with the stock numbers!\n") |
|
184 |
|
|
|
185 |
|
print("\nOpen your amazon storage report and save it as an csv.\n") |
|
186 |
|
|
|
187 |
|
step += 1 |
|
188 |
|
try: |
|
189 |
|
stocklist = askopenfilename(initialdir=recent_path, |
|
190 |
|
title="The Stockreport from Amazon as .csv", |
|
191 |
|
filetypes=[ ("csv files", "*.csv") ]) |
|
192 |
|
print("spreadsheet csv containing the FNSKU and ASIN : ", stocklist) |
|
193 |
|
except OSError as fexc: |
|
194 |
|
fileNotFoundLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name=fexc) |
|
195 |
|
|
|
196 |
|
step += 1 |
|
197 |
|
try: |
|
198 |
|
EANUpload(sheet, export, stocklist, upload_folder) |
|
199 |
|
except KeyError as kexc: |
|
200 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
201 |
|
except UnboundLocalError as uexc: |
|
202 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
203 |
|
|
|
204 |
|
print("\nCreate a upload file for the SKU and Parent_SKU\nto connect existing items from amazon to plentyMarkets.\n") |
|
205 |
|
|
|
206 |
|
step += 1 |
|
207 |
|
try: |
|
208 |
|
amazonSkuUpload(sheet, export, upload_folder) |
|
209 |
|
except KeyError as kexc: |
|
210 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
211 |
|
except UnboundLocalError as uexc: |
|
212 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
213 |
|
except EmptyFieldWarning as eexc: |
|
214 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
215 |
|
|
|
216 |
|
print("\nCreate a upload file for the additional Information to Amazon Products like bullet points, lifestyle etc.\n") |
|
217 |
|
|
|
218 |
|
step += 1 |
|
219 |
|
try: |
|
220 |
|
amazonDataUpload(sheet, export, upload_folder) |
|
221 |
|
except KeyError as kexc: |
|
222 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
223 |
|
except UnboundLocalError as uexc: |
|
224 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
225 |
|
except EmptyFieldWarning as eexc: |
|
226 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
227 |
|
|
|
228 |
|
print("\nCollect the ASIN Numbers matching to the Variationnumber(Sku) and format them into the dataformat format.\n") |
|
229 |
|
|
|
230 |
|
step += 1 |
|
231 |
|
try: |
|
232 |
|
asinUpload(export, stocklist, upload_folder) |
|
233 |
|
except KeyError as kexc: |
|
234 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
235 |
|
except UnboundLocalError as uexc: |
|
236 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
237 |
|
except EmptyFieldWarning as eexc: |
|
238 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
239 |
|
|
|
240 |
|
print("\nCollect the imagelinks from the flatfile, sorts them and assigns the variation ID.\n") |
|
241 |
|
|
|
242 |
|
step += 1 |
|
243 |
|
try: |
|
244 |
|
imageUpload(sheet, export, upload_folder) |
|
245 |
|
except KeyError as kexc: |
|
246 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
247 |
|
except UnboundLocalError as uexc: |
|
248 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
249 |
|
except Exception as err: |
|
250 |
|
print(err) |
|
251 |
|
print("Image Upload failed!") |
|
252 |
|
|
|
253 |
|
print("\nActivate Marketconnection for Ebay & Amazon for all variation.\n") |
|
254 |
|
|
|
255 |
|
step += 1 |
|
256 |
|
try: |
|
257 |
|
marketConnection(export, upload_folder, ebay=1, amazon=1, shop=1) |
|
258 |
|
except KeyError as kexc: |
|
259 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
260 |
|
except UnboundLocalError as uexc: |
|
261 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
262 |
|
except EmptyFieldWarning as eexc: |
|
263 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
264 |
|
except Exception as err: |
|
265 |
|
print(err) |
|
266 |
|
print("Market connection failed!") |
|
267 |
|
|
|
268 |
|
del moveon |
|
269 |
|
del fexc |
|
|
181 |
|
try: |
|
182 |
|
export['path'] = askopenfilename(initialdir=recent_path, |
|
183 |
|
title="The Export File from Plentymarkets as .csv", |
|
184 |
|
filetypes=[ ("csv files", "*.csv") ]) |
|
185 |
|
|
|
186 |
|
export['encoding'] = check_encoding(export) |
|
187 |
|
except OSError as fexc: |
|
188 |
|
fileNotFoundLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name=fexc) |
|
189 |
|
except Exception as exc: |
|
190 |
|
print(exc) |
|
191 |
|
print("Something went wrong at the Export file import!") |
|
192 |
|
|
|
193 |
|
print("spreadsheet csv containing the export : ", export) |
|
194 |
|
|
|
195 |
|
try: |
|
196 |
|
print("Active, properties , features & price Upload") |
|
197 |
|
step += 1 |
|
198 |
|
for name in features: |
|
199 |
|
featureUpload(flatfile=sheet, feature=name, feature_id=features[name], folder=upload_folder) |
|
200 |
|
|
|
201 |
|
step += 1 |
|
202 |
|
setActive(sheet, export, upload_folder) |
|
203 |
|
step += 1 |
|
204 |
|
itemPropertyUpload(sheet, export, upload_folder) |
|
205 |
|
step += 1 |
|
206 |
|
priceUpload(sheet, export, upload_folder) |
|
207 |
|
except KeyError as kexc: |
|
208 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
209 |
|
except UnboundLocalError as uexc: |
|
210 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
211 |
|
except EmptyFieldWarning as eexc: |
|
212 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
213 |
|
except OSError as err: |
|
214 |
|
print(err) |
|
215 |
|
print("Missing Data, check if you have\n - a flatfile\n - a intern file table\n - export file from plentymarkets\n - a sheet with the stock numbers!\n") |
|
216 |
|
|
|
217 |
|
print("\nOpen your amazon storage report and save it as an csv.\n") |
|
218 |
|
|
|
219 |
|
step += 1 |
|
220 |
|
try: |
|
221 |
|
stocklist['path'] = askopenfilename(initialdir=recent_path, |
|
222 |
|
title="The Stockreport from Amazon as .csv", |
|
223 |
|
filetypes=[ ("csv files", "*.csv") ]) |
|
224 |
|
|
|
225 |
|
stocklist['encoding'] = check_encoding(stocklist) |
|
226 |
|
print("spreadsheet csv containing the FNSKU and ASIN : ", stocklist) |
|
227 |
|
except OSError as fexc: |
|
228 |
|
fileNotFoundLog(log_path=log_folder, step_number=step, step_desc=step_name[step], file_name=fexc) |
|
229 |
|
|
|
230 |
|
step += 1 |
|
231 |
|
try: |
|
232 |
|
EANUpload(sheet, export, stocklist, upload_folder) |
|
233 |
|
except KeyError as kexc: |
|
234 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
235 |
|
except UnboundLocalError as uexc: |
|
236 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
237 |
|
|
|
238 |
|
print("\nCreate a upload file for the SKU and Parent_SKU\nto connect existing items from amazon to plentyMarkets.\n") |
|
239 |
|
|
|
240 |
|
step += 1 |
|
241 |
|
try: |
|
242 |
|
amazonSkuUpload(sheet, export, upload_folder) |
|
243 |
|
except KeyError as kexc: |
|
244 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
245 |
|
except UnboundLocalError as uexc: |
|
246 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
247 |
|
except EmptyFieldWarning as eexc: |
|
248 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
249 |
|
|
|
250 |
|
print("\nCreate a upload file for the additional Information to Amazon Products like bullet points, lifestyle etc.\n") |
|
251 |
|
|
|
252 |
|
step += 1 |
|
253 |
|
try: |
|
254 |
|
amazonDataUpload(sheet, export, upload_folder) |
|
255 |
|
except KeyError as kexc: |
|
256 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
257 |
|
except UnboundLocalError as uexc: |
|
258 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
259 |
|
except EmptyFieldWarning as eexc: |
|
260 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
261 |
|
|
|
262 |
|
print("\nCollect the ASIN Numbers matching to the Variationnumber(Sku) and format them into the dataformat format.\n") |
|
263 |
|
|
|
264 |
|
step += 1 |
|
265 |
|
try: |
|
266 |
|
asinUpload(export, stocklist, upload_folder) |
|
267 |
|
except KeyError as kexc: |
|
268 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
269 |
|
except UnboundLocalError as uexc: |
|
270 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
271 |
|
except EmptyFieldWarning as eexc: |
|
272 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
273 |
|
|
|
274 |
|
print("\nCollect the imagelinks from the flatfile, sorts them and assigns the variation ID.\n") |
|
275 |
|
|
|
276 |
|
step += 1 |
|
277 |
|
try: |
|
278 |
|
imageUpload(sheet, export, upload_folder) |
|
279 |
|
except KeyError as kexc: |
|
280 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
281 |
|
except UnboundLocalError as uexc: |
|
282 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
283 |
|
except Exception as err: |
|
284 |
|
print(err) |
|
285 |
|
print("Image Upload failed!") |
|
286 |
|
|
|
287 |
|
print("\nActivate Marketconnection for Ebay & Amazon for all variation.\n") |
|
288 |
|
|
|
289 |
|
step += 1 |
|
290 |
|
try: |
|
291 |
|
marketConnection(export, upload_folder, ebay=1, amazon=1, shop=1) |
|
292 |
|
except KeyError as kexc: |
|
293 |
|
keyErrorLog(log_path=log_folder, step_number=step, step_desc=step_name[step], key_name=kexc, file_name=ntpath.basename(sheet)) |
|
294 |
|
except UnboundLocalError as uexc: |
|
295 |
|
unboundLocalLog(log_path=log_folder, step_number=step, step_desc=step_name[step], filename=ntpath.basename(sheet), variable_name=uexc.args) |
|
296 |
|
except EmptyFieldWarning as eexc: |
|
297 |
|
emptyFieldWarningLog(log_path=log_folder, step_number=step, step_desc=step_name[step], field_name=eexc.errorargs, file_name=ntpath.basename(sheet)) |
|
298 |
|
except Exception as err: |
|
299 |
|
print(err) |
|
300 |
|
print("Market connection failed!") |
|
301 |
|
|
|
302 |
|
del fexc |
|
303 |
|
else: |
|
304 |
|
print("Choose a category and a name.\n") |
270 |
305 |
if __name__ == '__main__': |
if __name__ == '__main__': |
271 |
306 |
main() |
main() |