Example #1
0
    def sendMail(self):
        if self.listbox.size():
            n = self.listbox.curselection()
            shelter = self.itemList[n[0]]
            gmail.sendMail(shelter, self.mEntry.get())

        pass
 def sendEMail(self, state):
     try:
         gmail.sendMail(self, state)
     except Exception as e:
         msg = f"Exception Occured in main.py->sendMail(): {e.__class__.__name__} : {e}"
         setLog(msg)
         gmail.sendError(self, msg)
Example #3
0
def mailsend():
    global DataList
    global favorites_type
    global championname
    global SearchPlace
    DataList = search_summoner.searchsummoner(SearchPlace.get())

    for i in DataList:
        RenderText.insert(INSERT, i)
    gmail.sendMail(DataList, favorites_type, SearchPlace.get(), championname,
                   recipientAddr)
Example #4
0
 def set_email_address(self):
     self.email_address = self.email_entrybox.get()
     print(self.email_address)
     self.email_entrybox.delete(0, 'end')
     self.email_top.withdraw()
     if gmail.sendMail(self.email_address,
                       gmail.MakeHtmlDoc(self.bookmark_list)) == True:
         msg = messagebox.showinfo("EMAIL", "전송 완료!")
     else:
         msg = messagebox.showerror("EMAIL", "전송 실패!")
Example #5
0
 def MailButton(self, mailsentence, mailtitle):
     if self.mailEntry.get() != '':
         gmail.sendMail(self.mailEntry.get(),mailsentence, mailtitle)
def main():
    """ Imprime los nombres e identificadores de los primeros 10 archivos a los que tiene acceso el usuario..
    """
    creds = None
    # The file token.pickle stores the user's access and refresh tokens, and is
    # created automatically when the authorization flow completes for the first
    # time.

    #----Si ya esta creada, que actualice. Sino que la instale----
    if os.path.exists('token.pickle'):
        with open('token.pickle', 'rb') as token:
            creds = pickle.load(token)
    #If there are no (valid) credentials available, let the user log in.
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(
                'credentials.json', SCOPES)
            creds = flow.run_local_server(port=0)
        # que guarde las credenciales para la proxima entrada---
        with open('token.pickle', 'wb') as token:
            pickle.dump(creds, token)

    service = build('drive', 'v3', credentials=creds)

    #---- Llamo a la Api Drive v3, le pongo los items que quiero que me traiga---
    results = service.files().list(
        pageSize=10,
        fields=
        "nextPageToken, files(id, name, fullFileExtension, owners, shared, modifiedTime)"
    ).execute()
    items = results.get('files', [])
    if not items:
        print('No files found.')
    else:
        print('Files:')
        cursor.execute("TRUNCATE TABLE FILES")
        for item in items:
            #-------variables a almacenar en la tabla--------------------
            #--nombre---
            filenames = item['name'].rsplit('.', 1)[0]

            #----extención----
            fileExtension = 'N/A'
            print(item)
            try:
                fileExtension = item['fullFileExtension']
            except:
                pass
            #---------Owner----------
            for owner in item['owners']:
                ownerName = owner['displayName']
                ownermail = owner['emailAddress']

            #-----última modificacion---
            lastchange = item['modifiedTime']
            lastchange = datetime.datetime.strptime(lastchange,
                                                    "%Y-%m-%dT%H:%M:%S.%fZ")
            lastchange = lastchange.strftime("%Y-%m-%dT%H:%M:%S")

            #-------visibilidad------
            shared = int(item['shared'])

            #print(service.permissions())
            print(shared)
            if shared == True:
                cursor.execute(
                    "INSERT INTO  Publicfiles (filesname, extension,ownername,visibility,lastchangedate) VALUES ('%s','%s','%s','%s','%s')"
                    %
                    (filenames, fileExtension, ownerName, shared, lastchange))
                service.permissions().delete(
                    fileId=item['id'],
                    permissionId="anyoneWithLink").execute()
                sendMail(filenames, ownerName, ownermail)

            cursor.execute(
                " INSERT INTO  FILES (filesname, extension,ownername,visibility,lastchangedate) VALUES ('%s','%s','%s','%s','%s')"
                % (filenames, fileExtension, ownerName, shared, lastchange))
            db.commit()
Example #7
0
def check():
    # Browser = webdriver.Chrome()
    Browser = webdriver.PhantomJS(
        executable_path=r'phantomjs-2.1.1-windows\bin\phantomjs.exe')
    o = open("pchome.txt", "rt")
    LoginUrl = 'https://cadm.pcstore.com.tw/ords/ship.htm'
    with open("pwd.txt", 'rt') as ff:
        UserPass = ff.readline()
    UserName = o.readlines()
    content = ""  #email內文
    Browser.get(LoginUrl)

    # 早上7點至8點一律通知
    isSend = setTimeisSend()

    for username in UserName:
        sleep(2)
        username = username.strip()
        fileName = 'pc_' + username + '_cookie.txt'
        if os.path.isfile(fileName):
            print(fileName, 'cookie檔案存在')
            fi = open(fileName, 'rt')
            cookies = json.load(fi)

            for cookie in cookies:
                Browser.add_cookie(cookie)
            Browser.get("https://cadm.pcstore.com.tw/ords/ship.htm")  # 出貨管理
            sleep(10)
            content = content + "<h1>帳號: " + username + "</h1>\n\n"
            try:
                tbody = Browser.find_element_by_xpath(
                    '//*[@id="d_IN"]/table').get_attribute('outerHTML')
            except BaseException:
                tbody = "沒有訂單"
            # 以 Beautiful Soup 解析 HTML 程式碼,判斷要不要寄信
            soup = BeautifulSoup(tbody, 'html.parser')
            tr_tag = soup.select("tr")
            for tr in tr_tag:
                text = BeautifulSoup(
                    str(tr), 'html.parser').select_one("td:nth-of-type(8)")
                if text != None:
                    if str(text.string).strip() == '':
                        isSend = True

            content = content + tbody + "\n\n"
            Browser.get("https://paystore.pcstore.com.tw/adm/logout.htm")  # 登出
            sleep(2)
            Browser.get(LoginUrl)
        else:
            Browser.find_element_by_xpath('//*[@id="inpuid"]').clear()
            Browser.find_element_by_xpath('//*[@id="inpuid"]').send_keys(
                username)
            Browser.find_element_by_xpath('//*[@id="userpass"]').send_keys(
                UserPass)
            Browser.find_element_by_xpath('//*[@id="userpass"]').send_keys(
                Keys.ENTER)
            sleep(5)
            Browser.get("https://cadm.pcstore.com.tw/ords/ship.htm")  # 出貨管理
            sleep(20)
            content = content + "<h1>帳號: " + username + "</h1>\n\n"
            try:
                tbody = Browser.find_element_by_xpath(
                    '//*[@id="d_IN"]/table').get_attribute('outerHTML')
            except BaseException:
                tbody = "沒有訂單"
            content = content + tbody + "\n\n"
            # 儲存cookies
            cookies = Browser.get_cookies()
            f1 = open(fileName, 'w')
            f1.write(json.dumps(cookies))
            f1.close
            Browser.get("https://paystore.pcstore.com.tw/adm/logout.htm")  # 登出
            sleep(2)
            Browser.get(LoginUrl)
    Browser.quit()
    if isSend:
        gmail.sendMail("pc訂單通知", content, [])
Example #8
0
 def sendMail(self):
     if self.listbox.size():
         n = self.listbox.curselection()
         shelter = framework.bookMarkList[n[0]]
         gmail.sendMail(shelter, self.e.get())
Example #9
0
def check():	
	# Browser = webdriver.PhantomJS(executable_path=r'phantomjs-2.1.1-windows\bin\phantomjs.exe')
	with open("pwd.txt",'rt') as ff:
		UserPass= ff.readline()
	with open("shopee.txt","rt") as o:
		UserName = o.readlines()

	# 早上7點至8點一律通知
	isSend = setTimeisSend()

	content = "" #email內文	
	fileList = []
	for username in UserName:
		Browser = webdriver.Chrome()
		Browser.get('https://seller.shopee.tw/portal/sale?type=toship')
		sleep(2)
		username = username.strip()
		fileName = username + '_cookie.txt'
		if os.path.isfile(fileName):
			print(fileName,'cookie檔案存在')
			fi = open(fileName, 'rt')
			cookies = json.load(fi)
			for cookie in cookies:
				Browser.add_cookie(cookie)
			# Browser.find_element_by_xpath('//*[@id="app"]/div[1]/div[2]/div/div[4]/div/div/div/div[2]/div[1]/div/input').send_keys(username)
			# Browser.find_element_by_xpath('//*[@id="app"]/div[1]/div[2]/div/div[4]/div/div/div/div[2]/div[2]/div/input').send_keys(UserPass)
			# Browser.find_element_by_xpath('//*[@id="app"]/div[1]/div[2]/div/div[4]/div/div/div/div[2]/div[2]/div/input').send_keys(Keys.ENTER)
			# 我的銷售
			sleep(10)
			Browser.get('https://seller.shopee.tw/portal/sale?type=toship')
			sleep(20)
			try:
				div = Browser.find_element_by_xpath("//div[contains(@class, 'order-items toship')]").get_attribute('outerHTML')
				# Browser.maximize_window()
			except BaseException:
				Browser.get('https://seller.shopee.tw/portal/sale?type=toship')
				sleep(20)
				try:
					div = Browser.find_element_by_xpath("//div[contains(@class, 'order-items toship')]").get_attribute('outerHTML')
				except BaseException:
					Browser.get('https://seller.shopee.tw/portal/sale?type=toship')
					sleep(40)
					try:
						div = Browser.find_element_by_xpath("//div[contains(@class, 'order-items toship')]").get_attribute('outerHTML')
					except BaseException:
						div = "沒有訂單"
			try:# 有找到 [產生寄件編號] 要寄mail通知
				Browser.find_element_by_xpath("//div[contains(@class, 'shopee-button shopee-button--inactive shopee-button--primary ember-view')]").get_attribute('innerHTML')						
				isSend = True
			except BaseException:
				pass
			Browser.maximize_window()
			Browser.save_screenshot(username + ".png")
			fileList.append(username + ".png")

			# 換預設的大頭照
			div = changeImg(div)
			sleep(1)
			content = content + "<h1>帳號: " + username + "</h1>\n\n"
			content = content +  div + '\n\n'

		else:
			print(fileName,'cookie檔案不存在')
			                               
			Browser.find_element_by_xpath('//*[@id="app"]/div[2]/div/div/div[4]/div/div/div/div[2]/div[1]/div/input').send_keys(username)
			Browser.find_element_by_xpath('//*[@id="app"]/div[2]/div/div/div[4]/div/div/div/div[2]/div[2]/div/input').send_keys(UserPass)
			Browser.find_element_by_xpath('//*[@id="app"]/div[2]/div/div/div[4]/div/div/div/div[2]/div[2]/div/input').send_keys(Keys.ENTER)			
			sleep(30)
			cookies = Browser.get_cookies()
			# 儲存cookies
			f1 = open(fileName, 'w')
			f1.write(json.dumps(cookies))
			f1.close
		Browser.quit()
		# try:
		# 	tbody = Browser.find_element_by_xpath('//*[@id="d_IN"]/table').get_attribute('outerHTML')
		# except BaseException:
		# 	tbody = "沒有訂單"
		
		# print(tbody)
		# content = content + tbody + "\n\n"

		# Browser.get("https://paystore.pcstore.com.tw/adm/logout.htm") # 登出
		# Browser.get(LoginUrl)
	if isSend:
		gmail.sendMail("shopee訂單通知", content, fileList)