Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladislav Rykov
THSO.server
Commits
bb27521a
Commit
bb27521a
authored
Apr 09, 2020
by
Vladislav Rykov
Browse files
range id fixed
parent
eeac5cff
Changes
4
Hide whitespace changes
Inline
Side-by-side
.misc.py.swp
0 → 100644
View file @
bb27521a
File added
misc.py
View file @
bb27521a
...
@@ -6,3 +6,36 @@ def rand_str(length):
...
@@ -6,3 +6,36 @@ def rand_str(length):
return
hexlify
(
os
.
urandom
(
length
//
2
))
return
hexlify
(
os
.
urandom
(
length
//
2
))
else
:
else
:
return
hexlify
(
os
.
urandom
(
length
//
2
+
1
))
return
hexlify
(
os
.
urandom
(
length
//
2
+
1
))
def
prep_id_range
(
devlist
):
r
=
range
(
1
,
255
)
for
dev
in
devlist
:
del
r
[
r
.
index
(
dev
[
1
])]
s
=
''
inr
=
False
for
i
in
range
(
len
(
r
)
-
1
):
if
r
[
i
+
1
]
-
r
[
i
]
>
1
:
if
inr
:
s
+=
str
(
r
[
i
])
+
'], '
inr
=
False
else
:
s
+=
str
(
r
[
i
])
+
', '
else
:
if
not
inr
:
s
+=
'['
+
str
(
r
[
i
])
+
'-'
inr
=
True
if
r
[
-
1
]
-
r
[
-
2
]
>
1
:
if
inr
:
s
+=
str
(
r
[
-
1
])
+
']'
else
:
s
+=
str
(
r
[
-
1
])
else
:
if
not
inr
:
s
+=
str
(
r
[
-
1
])
else
:
s
+=
str
(
r
[
-
1
])
+
']'
return
s
misc.pyc
View file @
bb27521a
No preview for this file type
server.py
View file @
bb27521a
...
@@ -10,10 +10,6 @@ APP_KEY_LEN = 8
...
@@ -10,10 +10,6 @@ APP_KEY_LEN = 8
server
=
Flask
(
__name__
,
template_folder
=
'templates/'
)
server
=
Flask
(
__name__
,
template_folder
=
'templates/'
)
def
prep_ids
(
dev_list
):
return
"any"
@
server
.
route
(
'/'
)
@
server
.
route
(
'/'
)
def
index
():
def
index
():
if
'name'
in
session
and
len
(
session
[
'name'
])
>
0
:
if
'name'
in
session
and
len
(
session
[
'name'
])
>
0
:
...
@@ -145,8 +141,6 @@ def delete_app():
...
@@ -145,8 +141,6 @@ def delete_app():
@
server
.
route
(
'/add-dev'
)
@
server
.
route
(
'/add-dev'
)
def
new_dev
():
def
new_dev
():
free_ids
=
'whatever'
dh
=
dd
.
DeviceDao
()
dh
=
dd
.
DeviceDao
()
dev_list
=
dh
.
get_list
(
session
[
'appkey'
])
dev_list
=
dh
.
get_list
(
session
[
'appkey'
])
...
@@ -155,7 +149,7 @@ def new_dev():
...
@@ -155,7 +149,7 @@ def new_dev():
if
not
dev_list
[
0
]:
if
not
dev_list
[
0
]:
return
render_template
(
'add-dev.html'
,
feedback
=
dev_list
[
1
])
return
render_template
(
'add-dev.html'
,
feedback
=
dev_list
[
1
])
else
:
else
:
return
render_template
(
'add-dev.html'
,
free_ids
=
prep_id
s
(
dev_list
[
1
]))
return
render_template
(
'add-dev.html'
,
free_ids
=
misc
.
prep_id
_range
(
dev_list
[
1
]))
...
...
Write
Preview
Supports
Markdown
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