Skip to content

Commit

Permalink
Catch up with some fixes - bumped version and fixes for edit plugin when
Browse files Browse the repository at this point in the history
examples cannot be found.
  • Loading branch information
stuaxo committed Nov 29, 2016
1 parent 679b1be commit 081a6e0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1,5 +1,5 @@
name Shoebot
desc vector graphics scripting application
version 1.2.1
version 1.2.2
url http://shoebot.net
packager Ricardo Lafuente <r@manufacturaindependente.org>
6 changes: 4 additions & 2 deletions extensions/gedit/gedit3.12-plugin/shoebotit/__init__.py
Expand Up @@ -294,9 +294,11 @@ def mk_menu(text):
item = Gio.MenuItem.new_submenu(text, menu)

examples_item, examples = gtk3_utils.mk_examples_menu(_("E_xamples"))
if not EXAMPLES:

if examples and not EXAMPLES:
# if examples is None, examples were not found.
EXAMPLES.extend(examples)
menu.append_item(examples_item)
menu.append_item(examples_item)

for text, name in WINDOW_ACTIONS:
menu.append(text, "win.on_%s" % name)
Expand Down
4 changes: 2 additions & 2 deletions extensions/lib/shoebotit/gtk3_utils.py
Expand Up @@ -86,9 +86,9 @@ def mk_examples_menu(text, root_dir=None, depth=0):
# 3.12+ menus
examples_dir = ide_utils.get_example_dir()
if not examples_dir:
return "", [], []
return None, []

root_dir = root_dir or examples_dir
root_dir = root_dir or examples_dir

file_actions = []

Expand Down
31 changes: 23 additions & 8 deletions extensions/lib/shoebotit/ide_utils.py
Expand Up @@ -16,9 +16,10 @@
import collections
import os
import subprocess
import sys
import textwrap
import threading
import time
import sys
import uuid
import re

Expand Down Expand Up @@ -271,31 +272,45 @@ def find_example_dir():
"""
Find examples dir .. a little bit ugly..
"""
# Replace %s with directory to check for shoebot menus.
code_stub = textwrap.dedent("""
from pkg_resources import resource_filename, Requirement, DistributionNotFound
try:
print(resource_filename(Requirement.parse('shoebot'), '%s'))
except DistributionNotFound:
pass
""")


# Needs to run in same python env as shoebot (may be different to gedits)
code = "from pkg_resources import resource_filename, Requirement; print resource_filename(Requirement.parse('shoebot'), 'share/shoebot/examples/')"
cmd = ["python", "-c", code]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
code = code_stub % 'share/shoebot/examples'
cmd = ["python", "-c", code]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, errors = p.communicate()
if errors:
print('Could not find shoebot examples')
print('Errors: {0}'.format(errors))
print('Shoebot experienced errors searching for install and examples.')
print('Errors:\n{0}'.format(errors.decode('utf-8')))
return None
else:
examples_dir = output.decode('utf-8').strip()
if os.path.isdir(examples_dir):
return examples_dir

# If user is running 'setup.py develop' then examples could be right here
code = "from pkg_resources import resource_filename, Requirement; print resource_filename(Requirement.parse('shoebot'), 'examples/')"
#code = "from pkg_resources import resource_filename, Requirement; print resource_filename(Requirement.parse('shoebot'), 'examples/')"
code = code_stub % 'examples/'
cmd = ["python", "-c", code]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output, errors = p.communicate()
examples_dir = output.decode('utf-8').strip()
if os.path.isdir(examples_dir):
return examples_dir

print('Could not find shoebot examples at {0}'.format(examples_dir))
if examples_dir:
print('Shoebot could not find examples at: {0}'.format(examples_dir))
else:
print('Shoebot could not find install dir and examples.')


def make_readable_filename(fn):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -185,7 +185,7 @@ def requirements(with_pgi=None, with_examples=True, debug=True):
"shoebot.grammar.nodebox-lib.nodebox.geo"
],
data_files=datafiles,
install_requires=requirements(debug="install" in sys.argv, with_examples="SHOEBOT_SKIP_EXAMPLES" not in os.environ),
install_requires=requirements(debug="install" in sys.argv, with_examples="SHOEBOT_SKIP_EXAMPLES" not in os.environ, with_pgi=is_pypy),
entry_points={
"console_scripts": [
"sbot=shoebot.run:main",
Expand Down

0 comments on commit 081a6e0

Please sign in to comment.