Example #1
0
def applications_with_device_id(name=None):
    deviceId = workflow.get_variable('deviceId')

    applications = Application.applications_with_device_id(deviceId)
    applications = applications if name is None else [
        d for d in applications
        if d.bundleDisplayName.lower().find(name.lower()) >= 0
    ]

    workflowApplications = []
    for application in applications:
        modifierSubtitles = {
            workflow.ItemMod.Shift: application.application_detail()
        }
        workflowApplications.append(
            workflow.Item(title=application.bundleDisplayName,
                          subtitle="Reveal content in Finder",
                          icon=application.icons[0]
                          if application.icons else "assets/noicon.png",
                          arg=application.bundleID,
                          autocomplete=application.bundleDisplayName,
                          valid=True,
                          uid=application.bundleID,
                          modifierSubtitles=modifierSubtitles))
    workflow.Item.generate_output(workflowApplications)
Example #2
0
def reset_data_application(bundleId):
    deviceId = workflow.get_variable('deviceId')
    application = Application.application_with_device_and_bundle(
        deviceId, bundleId)
    Application.reset_data(deviceId, bundleId)

    if application is not None:
        sys.stdout.write(application.bundleDisplayName)
        sys.stdout.flush()
Example #3
0
def uninstall_application(bundleId):
    deviceId = workflow.get_variable('deviceId')
    application = Application.application_with_device_and_bundle(
        deviceId, bundleId)

    # Launch simulator
    devnull = open(os.devnull, 'w')  # hiding the output
    subprocess.call(["xcrun", "instruments", "-w", deviceId],
                    stdout=devnull,
                    stderr=subprocess.STDOUT)

    # Launch app in simulator
    subprocess.call(["xcrun", "simctl", "uninstall", deviceId, bundleId])

    if application is not None:
        sys.stdout.write("{0} was deleted.".format(
            application.bundleDisplayName))
        sys.stdout.flush()
#coding: utf-8
import workflow
import editor
import clipboard
import datetime


entry_file = workflow.get_variable('entry_filename')
file_contents = editor.get_file_contents(entry_file)

if (file_contents):
    entry = file_contents
else:
    entry = 'empty'

daily_stats = workflow.get_variable('journal_stats')
print('daily_stats' + daily_stats)

editor.set_file_contents(filename, entry + '\n\n' + daily_stats)

workflow.set_variable('entry_text', content)
workflow.set_variable('entry_filename', filename)

clipboard.set(content)
workflow.set_output(content)
Example #5
0
def bundle_path(bundleId):
    deviceId = workflow.get_variable('deviceId')
    path = Application.bundle_path(deviceId, bundleId)
    subprocess.call(["open", "-R", path])
#coding: utf-8
import workflow
import editor
import clipboard
import datetime

raw_entry = workflow.get_variable('entry_text')

entry_name = 'Journal 0{:%Y-%m-%d}'.format(datetime.date.today())
content = '# ' + entry_name + '\n\n' + raw_entry
content = content.strip() + '\n'
filename = entry_name + '.markdown'
# daily_stats = workflow.get_variable('journal_stats')

editor.set_file_contents(filename, content)
#editor.set_file_contents(filename, content + '\n\n' + daily_stats)

workflow.set_variable('entry_text', content)
workflow.set_variable('entry_filename', filename)

clipboard.set(content)
workflow.set_output(content)
Example #7
0
# https://forum.omz-software.com/topic/2353/encoding-images-in-base64

# coding: utf-8

import workflow
import clipboard
import photos
import base64

source_selection = workflow.get_variable('source')

if source_selection == 'photo':
    image_selection = photos.pick_image()
else:
    image_selection = clipboard.get_image()
    if not image_selection:
        console.alert('No Image', 'Clipboard does not contain an image')
        
w, h = image_selection.size

encoded = base64.b64encode(str(image_selection)

workflow.set_variable('encodedImage', str(encoded))
        
workflow.set_variable('origSize', str(w))
Example #8
0
    ).encode("utf-8")


t = todoflow.from_files(todoflow.lists.to_list())

query_today = "@working and not @done"
query_next = "@next and not @done and not @working"

html_parts = [
    print_due(t),
    print_dates(t),
    print_query(t, "Working", query_today, "working"),
    print_query(t, "Next", query_next, "next"),
    '<a class="reload-button" id="reload-button" href="editorial://?command=TF:%20Agenda">Reload</a>',
]

action_out = "\n".join(html_parts).decode("utf-8")

import workflow

workflow.set_output(action_out)

import editor

if editor.get_theme() == "Dark":
    css = workflow.get_variable("dark css")
else:
    css = workflow.get_variable("light css")

workflow.set_variable("css", css.decode("utf-8"))
Example #9
0
#coding: utf-8

# this file is for the editorial app (ios) workflow to send a markdown here to convert to pdf.
import editor, requests, workflow

HEROKU = "SECRET"  # yeah this is crappy security but who cares? worst case scenario you HAXOR MY PANDOC INSTALLATION 1337 PWNAGE!!!

target = "https://" + HEROKU + "/mdpdf"

# this comes from workflow actions "get current file name" and then "set variable" (Input to "filename")
filename = workflow.get_variable("filename") + ".pdf"

markdown = editor.get_text(True)

data = {"filename": filename, "markdown": markdown}
response = requests.post(target, data=data)
pdf = response.content
editor.set_file_contents(filename, pdf, 'dropbox')

print('done!')

workflow.stop()
#coding: utf-8
import workflow, console, keychain, requests, editor
import re, json, base64, time

POSTS_DIR = '_posts'
BRANCH = 'master'
GITHUB_USER = '******'
GITHUB_EMAIL = '*****@*****.**'
COMMITTER = {'name': GITHUB_USER, 'email': GITHUB_EMAIL}
GITHUB_TOKEN = keychain.get_password(
    'RV: GitHub', 'Personal Access Token'
)  # Requires RV: GitHub Authorize workflow to store the token.
GITHUB_REPO = workflow.get_variable('repo')

content = editor.get_text()
date = time.localtime(time.time())
post_tags = set([
    'note'
])  # Assumes we're a note by default and we don't add other tags to notes.

if len(GITHUB_TOKEN) == 0 or len(GITHUB_REPO) == 0 or len(content) == 0:
    console.hud_alert("Whoops! Token, repository or content is not set.",
                      'error')
    workflow.stop()

# Determine if this is a post or a note from the content. The clue is if the first
# line starts with a `#`. If so, it's a post, else it's a note.
lines = content.splitlines()

if lines[0].startswith("#"):
    post_type = "post"
Example #11
0
import editor
import console
import os
import re
import sys
import codecs
import workflow
from StringIO import StringIO

# Set CSS theme
theme = editor.get_theme()
workflow.set_variable(
    'CSS',
    workflow.get_variable('CSS Dark' if theme == 'Dark' else 'CSS Light'))

# Set Variables
p = editor.get_path()
console.clear()
term = workflow.get_variable('Search Term')
pattern = re.compile(re.escape(term), flags=re.IGNORECASE)
term_array = term.split()
for i in range(len(term_array)):
    term_array[i] = re.escape(term_array[i])
from urllib import quote
dir = os.path.split(p)[0]
valid_extensions = set(
    ['.txt', '.md', '.markd', '.text', '.mdown', '.taskpaper'])
html = StringIO()
filename_match = 0
content_match = 0
match_count = 0
Example #12
0
import editor
import console
import os
import re
import sys
import codecs
import workflow
from StringIO import StringIO

# Set CSS theme
theme = editor.get_theme()
workflow.set_variable('CSS', workflow.get_variable('CSS Dark' if theme == 'Dark' else 'CSS Light'))

# Set Variables
p = editor.get_path()
console.clear()
term = workflow.get_variable('Search Term')
pattern = re.compile(re.escape(term), flags=re.IGNORECASE)
term_array = term.split()
for i in range(len(term_array)):
		term_array[i] = re.escape(term_array[i])
from urllib import quote
dir = os.path.split(p)[0]
valid_extensions = set(['.txt', '.md', '.markd', '.text', '.mdown', '.taskpaper'])
html = StringIO()
filename_match = 0
content_match = 0
match_count = 0

# Iterate over fienames against search terms and output if match found