Skip to content

Commit

Permalink
finished Python 3.8 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
GChristensen committed Oct 14, 2019
1 parent f7ccdc0 commit 891e3c6
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 42 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
##### xx.10.2019 (v.0.5.0)
* Migrated to Python 3.8
* Updated Cairo graphics library to the recent version (1.16.0)
* Dropped support of "~/.ensocommands" file

##### 11.10.2019 (v.0.4.6)
* Fixed command editor undo history.

Expand Down
2 changes: 1 addition & 1 deletion enso/debug.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
set PYTHONPATH=%~dp0

.\python\python .\scripts\run_enso.py -l INFO
.\python\python .\scripts\run_enso.py %*
12 changes: 10 additions & 2 deletions enso/enso/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# such strings).

# Enso version for use in UI
ENSO_VERSION = "0.4.6"
ENSO_VERSION = "0.5.0"

# Web UI can be disabled as a security option
ENABLE_WEB_UI = True
Expand Down Expand Up @@ -125,7 +125,15 @@
from ast import literal_eval

ENSO_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
ENSO_USER_DIR = os.path.expanduser(os.path.join("~", ".enso"))

ENSO_USER_DIR = None

HOME_DIR = os.getenv("HOME")
if HOME_DIR:
ENSO_USER_DIR = os.path.join(HOME_DIR, ".enso")

if not ENSO_USER_DIR:
ENSO_USER_DIR = os.path.expanduser(os.path.join("~", ".enso"))

ENSO_EXECUTABLE = os.path.join(ENSO_DIR, "run-enso.exe")
if not os.path.exists(ENSO_EXECUTABLE):
Expand Down
6 changes: 3 additions & 3 deletions enso/enso/contrib/retreat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


def installed():
# retereat_spec = importlib.util.find_spec('enso.contrib._retreat')
# if retereat_spec is not None:
# return True
retereat_spec = importlib.util.find_spec('enso.contrib._retreat')
if retereat_spec is not None:
return True
return False


Expand Down
6 changes: 3 additions & 3 deletions enso/enso/contrib/scriptotron/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ScriptTracker:
def __init__( self, eventManager, commandManager ):
self._scriptCmdTracker = ScriptCommandTracker( commandManager,
eventManager )
self._scriptFilename = os.path.expanduser(SCRIPTS_FILE_NAME)
#self._scriptFilename = os.path.expanduser(SCRIPTS_FILE_NAME)
from enso.providers import getInterface
self._scriptFolder = getInterface("scripts_folder")()
self._lastMods = {}
Expand Down Expand Up @@ -131,7 +131,7 @@ def _getCommandFiles( self ):

def _reloadPyScripts( self ):
self._scriptCmdTracker.clearCommands()
commandFiles = [self._scriptFilename] + self._getCommandFiles()
commandFiles = self._getCommandFiles()
print(commandFiles)
for f in commandFiles:
try:
Expand Down Expand Up @@ -161,7 +161,7 @@ def _reloadPyScripts( self ):
self._registerDependencies( allGlobals )

def _registerDependencies( self, allGlobals = None ):
baseDeps = [ self._scriptFilename ] + self._getCommandFiles()
baseDeps = self._getCommandFiles()

if allGlobals:
# Find any other files that the script may have executed
Expand Down
2 changes: 1 addition & 1 deletion enso/enso/platform/win32/shortcuts/Shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


my_documents_dir = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, 0, 0)
LEARN_AS_DIR = os.path.join(os.path.expanduser("~"), ".enso", "commands", "learned")
LEARN_AS_DIR = os.path.join(config.ENSO_USER_DIR, "commands", "learned")

# Check if Learn-as dir exist and create it if not
if (not os.path.isdir(LEARN_AS_DIR)):
Expand Down
2 changes: 1 addition & 1 deletion enso/enso/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_enso_set_config(key, value):

@app.route('/api/enso/get/config_dir')
def get_enso_get_config_dir():
return os.path.expanduser(config.ENSO_USER_DIR)
return config.ENSO_USER_DIR

@app.route('/api/enso/open/config_dir')
def get_enso_open_config_dir():
Expand Down
23 changes: 12 additions & 11 deletions enso/enso/webui/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ <h1><a id="user-content-configuring-enso" class="anchor" aria-hidden="true" href
<p>'Custom Initialization' block at the Enso <a href="/options.html">settings</a> page allows to specify any
Python code needed to initialize Enso. By using it, you may override variables from config.py or provide
values required by some commands. You can access variables declared at this block in your own commands through
the 'config' module. For example, you can obtain the following variable:
the 'config' module. For example, you can obtain <code>MY_VARIABLE</code> defined at the configuration block:
<p><pre><code>MY_VARIABLE = "my value"</code></pre></p>
<p>with the following code in your command:</p>
<p>in the following way at your command code:</p>
<p><pre><code>from enso import config<br>my_value = config.MY_VARIABLE</code></pre></p></p>

<h1><a id="user-content-creating-enso-commands" class="anchor" aria-hidden="true" href="#creating-enso-commands"></a>Creating Enso Commands</h1>
Expand Down Expand Up @@ -208,14 +208,15 @@ <h2><a id="user-content-command-updating" class="anchor" aria-hidden="true" href
use <code>yield</code> to relegate control back to Enso when it knows that some
operation will take a while to finish.</p>
<h2><a id="user-content-including-other-files" class="anchor" aria-hidden="true" href="#including-other-files"></a>Including Other Files</h2>
<p>Python's standard <code>import</code> statement can be used from command
scripts, of course. But the disadvantage of doing this with evolving
code is that imported modules won't be reloaded
if their contents change.<br>
It is possible to install or uninstall Python libraries from <a href="https://pypi.org/">PyPi</a>
<p>It is possible to install or uninstall Python libraries from <a href="https://pypi.org/">PyPi</a>
using 'enso install' and 'enso uninstall' commands respectively.<br>
If you need to import some code that is not installable as a Python module,
place it under the 'lib' folder at your Enso configuration directory (available at the Enso <a href="/options.html">settings</a> page).</p>
place it under the 'lib' folder at your Enso configuration directory (available at the Enso <a href="/options.html">settings</a> page).
<br>
Python's standard <code>import</code> statement can be used from command
scripts. But the disadvantage of doing this with evolving
code is that imported modules won't be reloaded
if their contents change.</p>

<h1><a id="user-content-mediaprobes" class="anchor" aria-hidden="true" href="#mediaprobes"></a>Mediaprobes</h1>
<p>Mediaprobes allow to create commands that automatically pass items found in filesystem (or listed
Expand All @@ -235,12 +236,12 @@ <h1><a id="user-content-mediaprobes" class="anchor" aria-hidden="true" href="#me
<li>prev - open the previous show in the player.</li>
<li>all - pass 'd:/tv-shows' to the player.</li>
</ul>
<p>It is possible to create probe commands based on a dictionary:</p>
<p><code>mediaprobe.dictionary_probe</code> allows to create probe commands based on a dictionary:</p>
<div class="highlight highlight-source-python"><pre>what_to_watch <span class="pl-k">=</span> {<span class="pl-s"><span class="pl-pds">"</span>formula 1<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>&lt;a link to my favorite formula 1 stream&gt;<span class="pl-pds">"</span></span>,
<span class="pl-s"><span class="pl-pds">"</span>formula e<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>&lt;a link to my favorite formula e stream&gt;<span class="pl-pds">"</span></span>}
cmd_watch <span class="pl-k">=</span> mediaprobe.dictionary_probe(<span class="pl-s"><span class="pl-pds">"</span>stream<span class="pl-pds">"</span></span>, what_to_watch, <span class="pl-s"><span class="pl-pds">"</span>&lt;absolute path to my network player&gt;<span class="pl-pds">"</span></span>)</pre></div>
<p>If player does not accept directories (as, for example, ACD See does), it is possible to pass a first file in the directory specified at
a dictionary:</p>
<p>If player does not accept directories (as, for example, ACD See does), use <code>mediaprobe.findfirst_probe</code> to pass a first file in a directory (one of the specified at
a dictionary):</p>
<pre><code>what_to_stare_at = {'nature': 'd:/images/nature',
'cosmos': 'd:/images/cosmos'}

Expand Down
27 changes: 19 additions & 8 deletions enso/scripts/run_enso.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,25 @@ def main(argv = None):
print("Showing console")
logging.basicConfig( level = loglevel )
else:
print("Hiding console")
user_log = os.path.join(config.ENSO_USER_DIR, "enso.log")
print("Logging into '%s'" % user_log)
sys.stdout = open(user_log, "w") #NullDevice()
sys.stderr = open(user_log, "w") #NullDevice()
logging.basicConfig(
filename = user_log,
level = loglevel )
print("Redirection output to: " + user_log)

logging.basicConfig(filename=user_log, level=loglevel)
user_log_file = open(user_log, "wb", 0)

class log():
def __init__(self):
self.file = user_log_file

def write(self, what):
self.file.write(what.encode())
self.file.flush()

def __getattr__(self, attr):
return getattr(self.file, attr)

sys.stdout = log()
sys.stderr = log()

if loglevel == logging.DEBUG:
print(opts)
Expand Down Expand Up @@ -207,7 +218,7 @@ def main(argv = None):
load_rc_config(default_enso_rc)

# legacy ensorc, currently undocumented
load_rc_config(os.path.expanduser("~/.ensorc"))
load_rc_config(os.path.join(config.HOME_DIR, ".ensorc"))

if opts.show_tray_icon:
# Execute tray-icon code in a separate thread
Expand Down
10 changes: 0 additions & 10 deletions platform/win32/Graphics/cairo/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,3 @@ Import( "env" )
# ----------------------------------------------------------------------------

env = env.Copy()

#from subprocess import call
#call("sh build.sh")

#bld = Builder(action = "sh build.sh", chdir=1)
#env.Append(BUILDERS = {'BuildCairo' : bld})
#env.BuildCairo(env.makeRootRelativePath( "done"), None)

#cairo = env.Command(env.makeRootRelativePath( "cairo/src/release/cairo.dll"), None, "sh build.sh")
#AlwaysBuild(cairo)
6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ Of course, you may construct dictionaries in various ways.
#### Change log
[full changelog](changelog.md)

##### 11.10.2019 (v.0.4.6)
* Fixed command editor undo history.
##### xx.10.2019 (v.0.5.0)
* Migrated to Python 3.8
* Updated Cairo graphics library to the recent version (1.16.0)
* Dropped support of "~/.ensocommands" file

#### Contributors

Expand Down

0 comments on commit 891e3c6

Please sign in to comment.