Пример #1
0
 def ocr_exe(self, dialog):
     if self.Engine == 0:
         try:
             self.Credential = CredentialManager.CredentialManager(True)
         except Exception:
             return errorCodes.NET_ERROR  #ネットワーク関係のエラー
     for Path in self.OcrList:
         if dialog.cancel:  #キャンセル処理
             self.allDelete()
             self.SavedText = ""
             return errorCodes.CANCELED
         if not Path.exists():  #ファイルがなかった場合
             self.allDelete()
             self.SavedText = ""
             return errorCodes.FILE_NOT_FOUND
         wx.CallAfter(dialog.changeName, (Path.stem))
         if self.Engine == 0:  #googleの呼び出し
             if not self.Credential.isOK():
                 self.SavedText = ""
                 return errorCodes.NOT_AUTHORIZED
             self.Credential.Authorize()
             try:
                 text = self.tool.google_ocr(Path,
                                             self.Credential.credential)
             except (errors.HttpError) as error:
                 self.SavedText = ""
                 return errorCodes.GOOGLE_ERROR
         if self.Engine == 1:  #tesseractの呼び出し
             try:
                 text = self.tool.tesseract_ocr(Path, self.mode, dialog)
             except (UnidentifiedImageError):
                 self.allDelete()
                 self.SavedText = ""
                 return errorCodes.FILE_NOT_SUPPORTED
         if text == None:
             self.allDelete()
             self.SavedText = ""
             return errorCodes.CANCELED
         self.TextSave(Path.with_suffix(".txt"), text)  #ファイルに保存
     return errorCodes.OK
Пример #2
0
# Dependencies: CredentialManager
#   tiny.cc/credentialManager
#
# Run Instructions:
#   python TextPeople.py
######################################################

to = raw_input("To: ")
from_ = raw_input("From: ")
message = raw_input("Message: ")

#Url for POST request
url = "https://api.sendgrid.com/api/mail.send.json"

#My Information
username = CredentialManager.get_value("SendGridUsername")
password = CredentialManager.get_value("SendGridPassword")

params = {
    "api_user": username,
    "api_key": password,
    "from": from_,
    "to": to,
    "subject": " ",
    "text": message
}

params = urllib.urlencode(params)

request = urllib.urlopen(url, params)
response = request.read()
Пример #3
0
# Run Instructions: 
#   python EmailAttachment.py fileName
######################################################


#If filename is commandline argument
if len(sys.argv) == 2:
    fileName = sys.argv[1];
else:
    fileName = raw_input("Enter file name: ");

#Url for POST request
url = "https://api.sendgrid.com/api/mail.send.json";

#My Information
username = CredentialManager.get_value("SendGridUsername");
password = CredentialManager.get_value("SendGridPassword");
from_ = "MBProCL";
to = "*****@*****.**"

#Parameters, same as usual
params = {
    "api_user": username,
    "api_key": password,
    "from": from_,
    "to": to,
    "subject": " ",
    "text": fileName,
};

#Current working directory + file name
Пример #4
0
#######################################################################
# Written by Ryan D'souza
#
# Takes a link, calls PDFLayer's API to get a PDF representation
# Of the text at that link
#
# Sends that PDF to my phone
#
# Dependency: CredentialManager.py
#   See: tiny.cc/credentialManager.py
#######################################################################

#MailGun information
mailGunURL = "https://api.mailgun.net/v3/sandboxee071b43671c4663b8790099f51085b7.mailgun.org/messages"
mailGunAuth = ('api', CredentialManager.get_value("MailGunAPIKey"))

#PDF Location
defaultSaveLocation = "/Users/Ryan/Dropbox/Screenshots/"
pdfLayerURL = "http://api.pdflayer.com/api/convert"
accessKey = CredentialManager.get_value("PDFLayerAPIKey")

linkToPDF = None

#If we got the link to the PDF as a parameter
if len(sys.argv) == 2:
    linkToPDF = sys.argv[1]

#Otherwise, just prompt for it
else:
    linkToPDF = raw_input("Enter link to screenshot: ")
Пример #5
0
import CredentialManager

#Tests CredentialManager.py

#Two ways to save credentials:

#1
CredentialManager.save_credentials("gmailUsernameKey", "secretUsername",
                                   "gmailPasswordKey", "secretPassword")
#2. Prompts for info to be entered
#Enter 'python CredentialManager.py' in terminal

CredentialManager.save_key("gmailUsername", "gmailPassword")

password = CredentialManager.get_value("gmailUsername")

if CredentialManager.does_key_exist("gmailUsername"):
    CredentialManager.delete_key("gmailUsername")
Пример #6
0
#
# Run:
#   python TextLink.py
#######################################################################


def compress_url(url):
    JSON = json.loads(
        urllib.urlopen(
            "http://po.st/api/shorten?longUrl=" + url +
            "&apiKey=3E5C05F5-DDED-4485-A193-F486E947F547", 'r').read())
    return JSON['short_url']


url = "https://api.sendgrid.com/api/mail.send.json"
to = CredentialManager.get_value("PHONE") + "@vtext.com"
from_ = "MBProCL"
username = CredentialManager.get_value("SendGridUsername")
password = CredentialManager.get_value("SendGridPassword")

#If a link has been included as a parameter
if len(sys.argv) == 2:

    #If the link URL is less than 150 chars
    if len(sys.argv[1]) <= 150:
        bodyText = sys.argv[1]

    #Else, compress it
    else:
        bodyText = compress_url(sys.argv[1])
Пример #7
0
#######################################################################
# Written by Ryan D'souza
#
# Takes a link, calls ScreenshotLayer's API to get a screenshot
# Of the text at that link
#
# Sends that screenshot to my phone
#
# Dependency: CredentialManager.py
#   See: tiny.cc/credentialManager.py
#######################################################################

#MailGun information
mailGunURL = "https://api.mailgun.net/v3/sandboxee071b43671c4663b8790099f51085b7.mailgun.org/messages"
mailGunAuth = ('api', CredentialManager.get_value("MailGunAPIKey"))

#Screenshot Layer Image Information
defaultSaveLocation = "/Users/Ryan/Dropbox/Screenshots/"

screenshotLayerURL = "http://api.screenshotlayer.com/api/capture"
accessKey = CredentialManager.get_value("ScreenshotLayerAPI")

linkToScreenshot = None

#If we got the link to screenshot as a parameter
if len(sys.argv) == 2:
    linkToScreenshot = sys.argv[1]

#Otherwise, just prompt for it
else:
Пример #8
0
import CredentialManager;

#Tests CredentialManager.py

#Two ways to save credentials:

#1
CredentialManager.save_credentials("gmailUsernameKey", "secretUsername", "gmailPasswordKey", "secretPassword");
#2. Prompts for info to be entered
#Enter 'python CredentialManager.py' in terminal

CredentialManager.save_key("gmailUsername", "gmailPassword");

password = CredentialManager.get_value("gmailUsername");

if CredentialManager.does_key_exist("gmailUsername"):
    CredentialManager.delete_key("gmailUsername");