Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
dda4a15b
Commit
dda4a15b
authored
Jul 09, 2015
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved from py23 to six python package.
parent
111c1870
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
895 additions
and
34 deletions
+895
-34
ardublocklyserver/py23/__init__.py
ardublocklyserver/py23/__init__.py
+0
-1
ardublocklyserver/py23/py23.py
ardublocklyserver/py23/py23.py
+0
-24
ardublocklyserver/requesthandler.py
ardublocklyserver/requesthandler.py
+21
-7
ardublocklyserver/six/LICENSE
ardublocklyserver/six/LICENSE
+18
-0
ardublocklyserver/six/README
ardublocklyserver/six/README
+16
-0
ardublocklyserver/six/__init__.py
ardublocklyserver/six/__init__.py
+0
-0
ardublocklyserver/six/six.py
ardublocklyserver/six/six.py
+838
-0
ardublocklyserver/sketchcreator.py
ardublocklyserver/sketchcreator.py
+2
-2
No files found.
ardublocklyserver/py23/__init__.py
deleted
100644 → 0
View file @
111c1870
ardublocklyserver/py23/py23.py
deleted
100644 → 0
View file @
111c1870
"""
This module contains some utilities to maintain compatibility between python 2.5+ and 3
"""
from
__future__
import
unicode_literals
,
absolute_import
import
sys
import
types
# Define different types for comparison
if
sys
.
version_info
[
0
]
==
3
:
string_type_compare
=
str
integer_type_compare
=
int
class_type_compare
=
type
else
:
string_type_compare
=
basestring
integer_type_compare
=
(
int
,
long
)
class_type_compare
=
(
type
,
types
.
ClassType
)
# Ensure unicode string from byte array
if
sys
.
version_info
[
0
]
==
3
:
def
b_unicode
(
x
):
return
x
.
decode
(
'utf-8'
)
else
:
def
b_unicode
(
x
):
return
str
(
x
).
encode
(
'utf-8'
)
ardublocklyserver/requesthandler.py
View file @
dda4a15b
...
...
@@ -11,7 +11,9 @@ import subprocess
import
time
import
json
import
cgi
import
sys
import
re
import
os
try
:
# 2.x name
import
Tkinter
...
...
@@ -25,7 +27,6 @@ except ImportError:
import
tkinter.filedialog
as
tkFileDialog
import
http.server
as
SimpleHTTPServer
from
ardublocklyserver.py23
import
py23
from
ardublocklyserver.compilersettings
import
ServerCompilerSettings
from
ardublocklyserver.sketchcreator
import
SketchCreator
...
...
@@ -46,7 +47,7 @@ class BlocklyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
if
content_type
==
'application/x-www-form-urlencoded'
:
parameters
=
urlparse
.
parse_qs
(
p
y23
.
b_unicode
(
self
.
rfile
.
read
(
content_length
)),
p
arse_qs_encoder
(
self
.
rfile
.
read
(
content_length
)),
keep_blank_values
=
False
)
message_back
=
handle_settings
(
parameters
)
elif
content_type
==
'text/plain'
:
...
...
@@ -92,6 +93,19 @@ class BlocklyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
self
.
requestline
,
str
(
code
),
str
(
size
))
def
parse_qs_encoder
(
url_to_encode
):
"""
The urlparse.parse_qs function requires an ASCII input in python 3 and a
unicode array in Python 2, so this helper function is used to return the
right data.
:return: Input string encoded in the format required by urlparse.parse_qs.
"""
if
sys
.
version_info
[
0
]
==
3
:
return
url_to_encode
.
decode
(
'utf-8'
)
else
:
return
str
(
url_to_encode
).
encode
(
'utf-8'
)
#################
# Main Handlers #
#################
...
...
@@ -188,11 +202,11 @@ def load_arduino_cli(sketch_path=None):
"""
Launches a command line that invokes the Arduino IDE to open, verify or
upload an sketch, which address is indicated in the input parameter
:param sketch_path:
:return: A tuple with the following data (output, error output, exit code)
"""
# Input sanitation and output defaults
if
not
isinstance
(
sketch_path
,
py23
.
string_type_compare
)
\
or
not
sketch_path
:
if
not
sketch_path
or
os
.
path
.
isdir
(
sketch_path
):
sketch_path
=
create_sketch_default
()
success
=
True
conclusion
=
''
...
...
@@ -241,7 +255,7 @@ def load_arduino_cli(sketch_path=None):
elif
ServerCompilerSettings
().
load_ide_option
==
'verify'
:
conclusion
=
'Successfully Verified Sketch'
cli_command
.
append
(
'--verify'
)
cli_command
.
append
(
sketch_path
)
cli_command
.
append
(
"%s"
%
sketch_path
)
#cli_command = ' '.join(cli_command)
print
(
'
\n\r
CLI command:'
)
print
(
cli_command
)
...
...
@@ -337,8 +351,8 @@ def browse_dir():
#####################
def
set_compiler_path
():
"""
Opens the file browser to select a file. Saves this filepath into
ServerCompilerSettings and if the filepath is different to that stored
Opens the file browser to select a file. Saves this file
path into
ServerCompilerSettings and if the file
path is different to that stored
already it triggers the new data to be saved into the settings file.
"""
new_path
=
browse_file
()
...
...
ardublocklyserver/six/LICENSE
0 → 100644
View file @
dda4a15b
Copyright (c) 2010-2015 Benjamin Peterson
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ardublocklyserver/six/README
0 → 100644
View file @
dda4a15b
Six is a Python 2 and 3 compatibility library. It provides utility functions
for smoothing over the differences between the Python versions with the goal of
writing Python code that is compatible on both Python versions. See the
documentation for more information on what is provided.
Six supports every Python version since 2.5. It is contained in only one Python
file, so it can be easily copied into your project. (The copyright and license
notice must be retained.)
Online documentation is at http://pythonhosted.org/six/.
Bugs can be reported to https://bitbucket.org/gutworth/six. The code can also
be found there.
For questions about six or porting in general, email the python-porting mailing
list: http://mail.python.org/mailman/listinfo/python-porting
ardublocklyserver/six/__init__.py
0 → 100644
View file @
dda4a15b
ardublocklyserver/six/six.py
0 → 100644
View file @
dda4a15b
This diff is collapsed.
Click to expand it.
ardublocklyserver/sketchcreator.py
View file @
dda4a15b
...
...
@@ -9,7 +9,7 @@
from
__future__
import
unicode_literals
,
absolute_import
import
os
from
ardublocklyserver.
py23
import
py23
from
ardublocklyserver.
six
import
six
from
ardublocklyserver.compilersettings
import
ServerCompilerSettings
...
...
@@ -48,7 +48,7 @@ class SketchCreator(object):
Return None indicates an error has occurred.
"""
sketch_path
=
self
.
build_sketch_path
()
if
isinstance
(
sketch_code
,
py23
.
string_type_compare
)
\
if
isinstance
(
sketch_code
,
six
.
string_types
)
\
and
sketch_code
:
code_to_write
=
sketch_code
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment