File product_import.py changed (mode: 100644) (index 1728a98..baafc96) |
1 |
1 |
from tkinter import Tk |
from tkinter import Tk |
2 |
2 |
from tkinter.filedialog import askopenfilename, askdirectory |
from tkinter.filedialog import askopenfilename, askdirectory |
3 |
3 |
import sys |
import sys |
|
4 |
|
import platform |
|
5 |
|
import os |
4 |
6 |
from packages.item_upload import itemUpload, itemPropertyUpload |
from packages.item_upload import itemUpload, itemPropertyUpload |
5 |
|
# from packages.attribute_upload import attributeUpload |
|
6 |
7 |
from packages.variation_upload import variationUpload, setActive, EANUpload, marketConnection |
from packages.variation_upload import variationUpload, setActive, EANUpload, marketConnection |
7 |
8 |
from packages.stock_upload import stockUpload, priceUpload |
from packages.stock_upload import stockUpload, priceUpload |
8 |
9 |
from packages.amazon_data_upload import amazonSkuUpload, amazonDataUpload, asinUpload, featureUpload |
from packages.amazon_data_upload import amazonSkuUpload, amazonDataUpload, asinUpload, featureUpload |
|
... |
... |
def main(): |
18 |
19 |
''' |
''' |
19 |
20 |
root = Tk() |
root = Tk() |
20 |
21 |
root.withdraw() |
root.withdraw() |
21 |
|
sheet = askopenfilename(initialdir="../", |
|
|
22 |
|
# Check if the os is Linux, in that case the initial directory is Documents |
|
23 |
|
# Unless Documents is not available in which case it is ~ |
|
24 |
|
initial_directory = '../' |
|
25 |
|
|
|
26 |
|
if(platform.system() == 'Linux'): |
|
27 |
|
if(os.path.exists(path='/home/' + os.getlogin() + '/Documents/')): |
|
28 |
|
initial_directory = '/home/' + os.getlogin() + '/Documents/' |
|
29 |
|
else: |
|
30 |
|
initial_directory = '/home/' + os.getlogin() |
|
31 |
|
|
|
32 |
|
sheet = askopenfilename(initialdir=initial_directory, |
22 |
33 |
title="Amazon Flatfile as .csv", |
title="Amazon Flatfile as .csv", |
23 |
34 |
filetypes=[ ("csv files", "*.csv") ]) |
filetypes=[ ("csv files", "*.csv") ]) |
24 |
|
intern_number = askopenfilename(initialdir="../", |
|
|
35 |
|
intern_number = askopenfilename(initialdir=initial_directory, |
25 |
36 |
title="The Intern Numbers as .csv", |
title="The Intern Numbers as .csv", |
26 |
37 |
filetypes=[ ("csv files", "*.csv") ]) |
filetypes=[ ("csv files", "*.csv") ]) |
27 |
|
upload_folder = askdirectory(initialdir="../", |
|
|
38 |
|
upload_folder = askdirectory(initialdir=initial_directory, |
28 |
39 |
title="Choose a folder for the upload files.") |
title="Choose a folder for the upload files.") |
29 |
|
erroritem = '' |
|
|
40 |
|
|
30 |
41 |
print("spreadsheet csv containing the flatfile : ", sheet) |
print("spreadsheet csv containing the flatfile : ", sheet) |
31 |
42 |
print("spreadsheet csv containing the intern numbers : ", intern_number) |
print("spreadsheet csv containing the intern numbers : ", intern_number) |
|
43 |
|
|
32 |
44 |
try: |
try: |
33 |
45 |
print("\nItem Upload\n") |
print("\nItem Upload\n") |
34 |
|
erroritem = itemUpload(sheet, intern_number, upload_folder) |
|
|
46 |
|
itemUpload(sheet, intern_number, upload_folder) |
35 |
47 |
except Exception as exc: |
except Exception as exc: |
36 |
48 |
print("Item Upload failed!\n") |
print("Item Upload failed!\n") |
37 |
49 |
print("Here: ", exc, '\n') |
print("Here: ", exc, '\n') |
|
... |
... |
def main(): |
40 |
52 |
e = sys.exc_info() |
e = sys.exc_info() |
41 |
53 |
for element in e: |
for element in e: |
42 |
54 |
print(element) |
print(element) |
|
55 |
|
|
43 |
56 |
try: |
try: |
44 |
57 |
print("\nVariation Upload\n") |
print("\nVariation Upload\n") |
45 |
58 |
variationUpload(sheet, intern_number, upload_folder) |
variationUpload(sheet, intern_number, upload_folder) |
|
... |
... |
def main(): |
55 |
68 |
moveon = input("Continue(ENTER)") |
moveon = input("Continue(ENTER)") |
56 |
69 |
|
|
57 |
70 |
print("\nGet a dataexport from the plentymarket site from the variation attributes, in order to access the current Variation ID.\n") |
print("\nGet a dataexport from the plentymarket site from the variation attributes, in order to access the current Variation ID.\n") |
|
71 |
|
|
58 |
72 |
try: |
try: |
59 |
73 |
export = askopenfilename(initialdir="../", |
export = askopenfilename(initialdir="../", |
60 |
74 |
title="The Export File from Plentymarkets as .csv", |
title="The Export File from Plentymarkets as .csv", |
|
... |
... |
def main(): |
64 |
78 |
except Exception as exc: |
except Exception as exc: |
65 |
79 |
print(exc) |
print(exc) |
66 |
80 |
print("Something went wrong at the Export file import!") |
print("Something went wrong at the Export file import!") |
|
81 |
|
|
67 |
82 |
print("spreadsheet csv containing the export : ", export) |
print("spreadsheet csv containing the export : ", export) |
|
83 |
|
|
68 |
84 |
try: |
try: |
69 |
85 |
print("Active, properties , features & price Upload") |
print("Active, properties , features & price Upload") |
70 |
|
featureUpload(sheet, 'color_map', 1, upload_folder) |
|
|
86 |
|
featureUpload(flatfile=sheet, feature='color_map', feature_id=1, folder=upload_folder) |
|
87 |
|
featureUpload(flatfile=sheet, feature='item_name', feature_id=13, folder=upload_folder) |
|
88 |
|
featureUpload(flatfile=sheet, feature='sleeve_type', feature_id=8, folder=upload_folder) |
|
89 |
|
featureUpload(flatfile=sheet, feature='pattern_type', feature_id=11, folder=upload_folder) |
|
90 |
|
featureUpload(flatfile=sheet, feature='collar_style', feature_id=12, folder=upload_folder) |
71 |
91 |
setActive(sheet, export, upload_folder) |
setActive(sheet, export, upload_folder) |
72 |
92 |
itemPropertyUpload(sheet, export, upload_folder) |
itemPropertyUpload(sheet, export, upload_folder) |
73 |
93 |
priceUpload(sheet, export, upload_folder) |
priceUpload(sheet, export, upload_folder) |
74 |
|
except FileNotFoundError as err: |
|
|
94 |
|
except FileNotFoundError as err:# pylint:disable=invalid-name,used-before-assignment |
75 |
95 |
print(err) |
print(err) |
76 |
96 |
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") |
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") |
77 |
97 |
sys.exit() |
sys.exit() |
|
98 |
|
|
78 |
99 |
print("\nOpen your amazon storage report and save it as an csv.\n") |
print("\nOpen your amazon storage report and save it as an csv.\n") |
|
100 |
|
|
79 |
101 |
stocklist = askopenfilename(initialdir="../", |
stocklist = askopenfilename(initialdir="../", |
80 |
102 |
title="The Stockreport from Amazon as .csv", |
title="The Stockreport from Amazon as .csv", |
81 |
103 |
filetypes=[ ("csv files", "*.csv") ]) |
filetypes=[ ("csv files", "*.csv") ]) |
82 |
104 |
print("spreadsheet csv containing the FNSKU and ASIN : ", stocklist) |
print("spreadsheet csv containing the FNSKU and ASIN : ", stocklist) |
83 |
105 |
|
|
84 |
106 |
EANUpload(sheet, export, stocklist, upload_folder) |
EANUpload(sheet, export, stocklist, upload_folder) |
85 |
|
#stockUpload(sheet, stocklist) |
|
86 |
107 |
|
|
87 |
108 |
print("\nCreate a upload file for the SKU and Parent_SKU\nto connect existing items from amazon to plentyMarkets.\n") |
print("\nCreate a upload file for the SKU and Parent_SKU\nto connect existing items from amazon to plentyMarkets.\n") |
88 |
109 |
|
|
|
... |
... |
def main(): |
97 |
118 |
asinUpload(export, stocklist, upload_folder) |
asinUpload(export, stocklist, upload_folder) |
98 |
119 |
|
|
99 |
120 |
print("\nCollect the imagelinks from the flatfile, sorts them and assigns the variation ID.\n") |
print("\nCollect the imagelinks from the flatfile, sorts them and assigns the variation ID.\n") |
|
121 |
|
|
100 |
122 |
try: |
try: |
101 |
123 |
imageUpload(sheet, export, upload_folder) |
imageUpload(sheet, export, upload_folder) |
102 |
124 |
except Exception as err: |
except Exception as err: |
|
... |
... |
def main(): |
111 |
133 |
print(err) |
print(err) |
112 |
134 |
print("Market connection failed!") |
print("Market connection failed!") |
113 |
135 |
|
|
114 |
|
# In case of new attributes uncomment and watch attribute_upload.py first |
|
115 |
|
# try: |
|
116 |
|
# attributeUpload(sheet) |
|
117 |
|
# except: |
|
118 |
|
# print("Attribute Upload failed!") |
|
119 |
|
|
|
120 |
|
|
|
121 |
136 |
if __name__ == '__main__': |
if __name__ == '__main__': |
122 |
137 |
main() |
main() |