Skip to content

Commit

Permalink
added windows utilities to the "open" command
Browse files Browse the repository at this point in the history
added UI_FONT config.py variable
  • Loading branch information
GChristensen committed May 7, 2024
1 parent 26712d7 commit 3d69305
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 47 deletions.
13 changes: 13 additions & 0 deletions enso/commands/dd_wrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,16 @@ def cmd_wan_reconnect(ensoapi):
tn.write(b"killall -HUP pppd\n")
tn.write(b"exit\n")
tn.read_all()


def cmd_restart_router(ensoapi):
"""Reboot dd-wrt"""
tn = Telnet(HOST, 23)
tn.read_until(b"login: ")
tn.write(USER + b"\n")
tn.read_until(b"Password: ")
tn.write(PASSWORD + b"\n")

tn.write(b"reboot\n")
tn.write(b"exit\n")
tn.read_all()
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 %*
.\python\python .\scripts\run_enso.py %* --debug
17 changes: 12 additions & 5 deletions enso/enso/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

# Web UI can be disabled as a security option
ENABLE_WEB_UI = True
# Enable CSRF protection
ENABLE_WEB_UI_CSRF = False

# Whether the Quasimode is actually modal ("sticky").
IS_QUASIMODE_MODAL = True
Expand Down Expand Up @@ -48,9 +50,12 @@
# auto-completion mechanism engages.
QUASIMODE_MIN_AUTOCOMPLETE_CHARS = 1

# Enso color theme
# Enso color themes
COLOR_THEME = "green"

# Enso display font
UI_FONT = "Arial"

# List of default platforms supported by Enso; platforms are specific
# types of providers that provide a suite of platform-specific
# functionality.
Expand All @@ -75,6 +80,12 @@
# If set to False, no locale is forced.dddasdfasdf
PLUGIN_GOOGLE_USE_DEFAULT_LOCALE = True

RETREAT_DISABLE = False

RETREAT_SHOW_ICON = True

DEBUG = False

import os

ENSO_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
Expand All @@ -100,10 +111,6 @@

CONFIG_FILE = os.path.join(ENSO_USER_DIR, "enso.cfg")

RETREAT_DISABLE = False

RETREAT_SHOW_ICON = True

DISABLED_COMMANDS = []
COMMAND_STATE_CHANGED = False

Expand Down
23 changes: 5 additions & 18 deletions enso/enso/graphics/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,11 @@ def loadInto( self, cairoContext ):
"""
Sets the cairo context's current font to this font.
"""


# TODO THE WINDOWS SPECIAL CASE WITH THE HARD-CODED PATH TO ARIAL
# IS A HORRIBLE HACK AND MUST BE FIXED ASAP (besides, Arial is
# ugly).
import sys
if sys.platform.startswith( "win" ):
cairoContext.select_font_face(
"c:/WINDOWS/Fonts/arial.ttf",
self.slant,
cairo.FONT_WEIGHT_NORMAL
)
else:
cairoContext.select_font_face(
self.name,
self.slant,
cairo.FONT_WEIGHT_NORMAL
)
cairoContext.select_font_face(
self.name,
self.slant,
cairo.FONT_WEIGHT_NORMAL
)

cairoContext.set_font_size( self.size )

Expand Down
3 changes: 2 additions & 1 deletion enso/enso/messages/primarywindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import logging

from enso import config
from enso import graphics
from enso.graphics import xmltextlayout
from enso.graphics.measurement import inchesToPoints
Expand Down Expand Up @@ -430,7 +431,7 @@ def __onAnimationFinished( self ):
"document",
margin_top = "0.0pt",
margin_bottom = "0.0pt",
font_family = "Gentium",
font_family = config.UI_FONT,
font_style = "normal",
max_lines = "0",
ellipsify = "false",
Expand Down
15 changes: 9 additions & 6 deletions enso/enso/quasimode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,14 @@ def __commandSuggestionCaption( self, userText ):
def __canEnterQuasimode(self):
result = True

if self.__contextUtils:
if config.QUASIMODE_BYPASS_TO_RDP:
foregroundClass = self.__contextUtils.getForegroundClassNameUnicode()

if foregroundClass == "TscShellContainerClass":
result = False
try:
if self.__contextUtils:
if config.QUASIMODE_BYPASS_TO_RDP:
foregroundClass = self.__contextUtils.getForegroundClassNameUnicode()

if foregroundClass == "TscShellContainerClass":
result = False
except:
pass

return result
3 changes: 2 additions & 1 deletion enso/enso/quasimode/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
# Imports
# ----------------------------------------------------------------------------

from enso import config
from enso import graphics
from enso.graphics import xmltextlayout
from enso.utils.xml_tools import escape_xml
Expand Down Expand Up @@ -126,7 +127,7 @@ def _newLineStyleRegistry():
styles = xmltextlayout.StyleRegistry()
styles.add(
"document",
font_family = "Gentium",
font_family = config.UI_FONT,
font_style = "normal",
max_lines = "1",
)
Expand Down
4 changes: 2 additions & 2 deletions enso/enso/strings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Enso version for use in UI
ENSO_VERSION = "1.1"
ENSO_VERSION = "1.1.1"

# The message displayed when the user types some text that is not a command.
BAD_COMMAND_MSG = "<p><command>%s</command> is not a command.</p>" \
Expand Down Expand Up @@ -29,7 +29,7 @@
# Message XML for the Splash message shown when Enso is refreshed.
REFRESHING_MSG_XML = "<p><command>Enso</command> is refreshed!</p>"

CLOSING_MSG_XML = "<p>Closing Enso...</p><caption>Enso</caption>"
CLOSING_MSG_XML = "<p>Closing <command>Enso...</command></p>"

# Message XML displayed when the mouse hovers over a mini message.
MINI_MSG_HELP_XML = "<p>The <command>hide mini messages</command>" \
Expand Down
4 changes: 2 additions & 2 deletions enso/enso/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
def requires_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
#if not request.authorization or request.authorization["password"] != AUTH_TOKEN:
# return abort(401)
if config.ENABLE_WEB_UI_CSRF and not request.authorization or request.authorization["password"] != AUTH_TOKEN:
return abort(401)
return f(*args, **kwargs)
return decorated

Expand Down
4 changes: 2 additions & 2 deletions enso/enso/webui/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ <h2 id="about-version">Version: </h2>
<div class="about-links" style="margin-top: 20px;">
<div id="donation-links">
Donate:
<img width="16px" height="16px" src="icons/patreon.png" style="margin-bottom: -2px;"/>
<!--<img width="16px" height="16px" src="icons/patreon.png" style="margin-bottom: -2px;"/>
<a class="about-link donation-link" href="https://patreon.com/gchristnsn" target="_blank">Patreon</a>
| <img width="16px" height="16px" src="icons/bitcoin.png" style="margin-bottom: -2px;"/>
<a class="about-link donation-link" href="bitcoin:1FR8zC1C4kv9PhUP85pUne1tX5KQi5iN8k" target="_blank">Bitcoin</a>
| <img width="16px" height="16px" src="icons/ethereum.svg" style="margin-bottom: -2px;"/>
| --><img width="16px" height="16px" src="icons/ethereum.svg" style="margin-bottom: -2px;"/>
<a class="about-link donation-link" href="ethereum:0x247F014AC714919aaD2243cefd7C00C0DaeBB2cc" target="_blank">Ethereum</a> </div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion enso/enso/webui/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h3>v0.1 <span class="change-date">September 6, 2018</span></h3>

<h3>v0.0.3 <span class="change-date">July 15, 2015</span></h3>
<ul class="change-info">
<li>Added the <b>capslock toggle</b> command (always dreamed of).</li>
<li>Added the <b>capslock toggle</b> command.</li>
</ul>

<h3>v0.0.2 <span class="change-date">May 28, 2015</span></h3>
Expand Down
21 changes: 19 additions & 2 deletions enso/enso/webui/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,24 @@ <h2><a id="user-content-class-based-commands" class="anchor" aria-hidden="true"

<span class="pl-k">def</span> <span class="pl-c1">__call__</span>(<span class="pl-smi"><span class="pl-smi">self</span></span>, <span class="pl-smi">ensoapi</span>, <span class="pl-smi">candidate</span>):
ensoapi.display_message(<span class="pl-s"><span class="pl-pds">"</span>You voted for: <span class="pl-c1">%s</span><span class="pl-pds">"</span></span> <span class="pl-k">%</span> candidate)

cmd_vote_for <span class="pl-k">=</span> VoteCommand([<span class="pl-s"><span class="pl-pds">"</span>barack obama<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>john mccain<span class="pl-pds">"</span></span>])</pre></div>

<h2><a id="user-content-multiline-messages" class="anchor" aria-hidden="true" href="#multiline-messages"></a>Multiline messages</h2>
<p>Messages displayed with <code></code>ensoapi.display_message()</code> can contain only one line.
If you need to display more than one line in your message, use the <code>displayMessage</code> function:</p>

<div class="highlight highlight-source-python">
<pre>
from enso.messages import displayMessage

MESSAGE_TEXT_XML = "&lt;p&gt;&lt;command&gt;Colored text&lt;/command&gt; white text.&lt;/p&gt;" \
"&lt;p&gt;Another line entirely in white.&lt;/p&gt;" \
"&lt;caption&gt;Small right-aligned caption&lt;/caption&gt;"

displayMessage(MESSAGE_TEXT_XML)
</pre>
</div>

<h2><a id="user-content-command-updating" class="anchor" aria-hidden="true" href="#command-updating"></a>Command Updating</h2>
<p>Some commands may need to do processing while not being executed; for
instance, an <code>open</code> command that allows the user to open an
Expand All @@ -216,7 +232,8 @@ <h2><a id="user-content-including-other-files" class="anchor" aria-hidden="true"
<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 in your Enso configuration directory (available on the Enso <a href="/options.html">settings</a> page).
place it under the 'lib' folder in your Enso configuration directory.
Its path could be found on 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
Expand Down
8 changes: 6 additions & 2 deletions enso/scripts/run_enso.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def process_options(argv):
default=True, help="Hide tray icon")
parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False,
help="No information windows are shown on startup/shutdown")
parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False,
help="Debug mode")

opts, args = parser.parse_args(argv)
return opts, args
Expand Down Expand Up @@ -198,17 +200,18 @@ def configure_logging(args, opts):
'DEBUG': logging.DEBUG
}[opts.loglevel]

user_log = os.path.join(config.ENSO_USER_DIR, "enso.log")

if opts.show_console:
print("Logging to console")
logging.basicConfig(level=loglevel, force=True)
else:
user_log = os.path.join(config.ENSO_USER_DIR, "enso.log")
print("Redirecting log output to: " + user_log)

logging.basicConfig(filename=user_log, level=loglevel, force=True)
logging.debug("test")

if opts.redirect_stdout:
if not opts.debug or opts.redirect_stdout:
print("Redirecting stdout output to: " + user_log)
user_log_file = open(user_log + ".stdout", "wb", 0)

Expand All @@ -230,6 +233,7 @@ def __getattr__(self, attr):
def main(argv = None):
opts, args = process_options(argv)
config.ENSO_IS_QUIET = opts.quiet
config.DEBUG = opts.debug

configure_logging(args, opts)

Expand Down
3 changes: 0 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,5 @@ <h4>Known issues</h4>
<li style="text-align: justify;">Some security tools may consider <b>run-enso.exe</b> as a potentially unwanted program. These are false-positive claims, since the launcher uses API needed to run other programs.</li>
</ul>

</section>
<footer>
</footer>
</body>
</html>
2 changes: 1 addition & 1 deletion setup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Unicode True

!define DIRNAME "Enso Launcher"
!define APPNAME "Enso Open-Source"
!define VERSION "1.1"
!define VERSION "1.1.1"

!include LogicLib.nsh

Expand Down

0 comments on commit 3d69305

Please sign in to comment.