Yann added a comment.

  I managed to do that
  
    retry_count = 3  # Number of upload retries
    success = False
    
    while retry_count > 0 and not success:
        try:
            filepage = pywikibot.FilePage(site, key)
            filepage.upload(
                source=filename,
                comment=desc_content,
                text=desc_content,
                chunk_size = "5M",
                ignore_warnings=False,
            )
            success = True
        except Exception as e:
            print("Upload failed. Retrying...")
            retry_count -= 1
    
    if not success:
        print("Upload failed after retries.")

TASK DETAIL
  https://phabricator.wikimedia.org/T338969

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Yann
Cc: Xqt, Aklapper, pywikibot-bugs-list, Yann, Udehb-WMF, PotsdamLamb, Jyoo1011, 
Y.ssk, JohnsonLee01, SHEKH, Dijkstra, Muchiri124, CBogen, Khutuck, Zkhalido, 
Viztor, Wenyi, Tbscho, MayS, Mdupont, JJMC89, Dvorapa, Altostratus, 
Taiwania_Justo, Avicennasis, Ixocactus, Wong128hk, mys_721tx, El_Grafo, 
Dinoguy1000, jayvdb, Masti, Alchimista, Steinsplitter, Krenair
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to