def exportToCsv():

    global results

    if results is None:
        gui.setStatus("There are no results to export.")
        return

    for key in results:
        results[key].insert(0, key)

    print(results)

    zipped = zip(results['created_at'], \
                    results['action'], \
                    results['entity_type'], \
                    results['entity_id'], \
                    results['unwrapped_error'])

    filepath = cu.writeListToCSV(output=zipped,
                                 title=f'channels-ticket{gui.getTicketNum()}',
                                 prefix=gui.getPrefix())

    gui.setStatus(f"Exported to {filepath}.")
Esempio n. 2
0
        if imageresp.status_code != 200:
            print(f"failed with {imageresp.status_code}...\n")
            addFailedData(currsku, currhandle, currlink)
            continue
        
        time.sleep(delay)

        print(f"success")
        uploadresp = api.uploadImage(pid, imageresp.content)

        if uploadresp.status_code != 201:
            print(f"Uploading image to {pid} failed with {uploadresp.status_code}...\n")
            addFailedData(currsku, currhandle, currlink)
            continue

        respdata = uploadresp.json()['data']

        print(f"Uploaded to {pid} position {respdata['position']}...{respdata['status']}\n")


uploadImages(skus,handles,links)


if len(failedskus) > 1:
    filename = cu.writeListToCSV(output=zip(failedskus, failedhandles, failedlinks), title=f'failed',prefix=domain)
        

        
        

emailtocodeLookup = {}

code_to_keep = ['merging_customer_code']
code_to_delete = ['deleting_customer_code']

emails = cu.getColumn(customercsv, "email")
cust_codes = cu.getColumn(customercsv, "customer_code")

i = 0

while i < len(emails):
    curr_email = emails[i].lower()
    curr_code = cust_codes[i]

    lookupcode = emailtocodeLookup.get(curr_email)

    if lookupcode is None:
        emailtocodeLookup[curr_email] = curr_code
        i += 1
        continue

    print(f"{lookupcode} to keep, {curr_code} to delete - matched on {curr_email}... {i+1} / {len(emails)}...")
    code_to_keep.append(lookupcode)
    code_to_delete.append(curr_code)

    i+=1


if len(code_to_delete) > 1:
    filename = cu.writeListToCSV(output=zip(code_to_keep, code_to_delete), title=f"mergingcustomer", prefix='')
    print(f"Exported to {filename}.")
Esempio n. 4
0

def createCustToId(custs):
    print(f"Creating code to id lookup for {len(custs)} customers...")
    for c in custs:
        cust_code = c['customer_code']
        cust_id = c['id']

        custToId[cust_code] = cust_id


def createRegIdtoReg(registers):

    for r in registers:
        reg_id = r['id']
        regidlookup[reg_id] = r


if __name__ == '__main__':

    createCustToId(customers)
    createRegIdtoReg(registers)
    mergeCustomers(deletecusts, mergingcusts)

    if len(failed_codes) > 1:
        filename = cu.writeListToCSV(output=zip(failed_ids, failed_sales,
                                                failed_codes, failed_response),
                                     title="failed_merge",
                                     prefix=prefix)
        print(f"Failed merge saved to {filename}.")
Esempio n. 5
0
        scode = resp.status_code

        print(scode)

        if scode != 204:
            print(f"Failed on {i}...")
            failed_ids.append(i)

        count += 1
        time.sleep(delay)


if __name__ == '__main__':

    allimageids = getAllImageIds(prodtoprocess)

    if len(allimageids) > 0:
        print(f"Starting bulk delete for {len(allimageids)} images...")

        deleteImages(allimageids)
    else:
        print("No images to delete.")

    if len(failed_ids) > 1:
        filename = cu.writeListToCSV(output=zip(failed_ids),
                                     title='failedimagedelete',
                                     prefix=domain)

        print(f"Saved {len(failed_ids)} failed image ids to {filename}.")