[web2py] scheduler can't normal run my script

2017-11-15 Thread yytrying
i write a scripy to get some information and use scheduler to auto ,but 
scheduler is display FAILED,this is my script

def redhat():
bug_num =''
try:
try:
url = 'https://access.redhat.com/security/vulnerabilities'
rea = requests.get(url)
rea.encoding = 'utf-8'
html = BeautifulSoup(rea.text,"html.parser")
a= html.find("tbody").find_all("tr")
try:
indatabase = db(db.get_data.get_from == "redhat").select()
if indatabase:
indatabase=db(db.get_data.get_from == "redhat").select(
db.get_data.title,orderby=~db.get_data.get_time,limitby
=(0,5))
else:
indatabase=['1']
except BaseException as e:
print e
for i in range(len(a)):
for j in indatabase:
break_flag ='no'
if a[i].find("a").get_text() != j.title:
geturl = 'https://access.redhat.com'+ str(a[i].find(
"a")).split('"')[1]
bug_level = a[i].find("div","field-type-list-text").
get_text().strip()
if re.findall(u'CVE\-[0-9]{4,}\-[0-9]{4,}',str(a[i].
find("a").get_text())):
bug_num = re.findall(u
'CVE\-[0-9]{4,}\-[0-9]{4,}',str(a[i].find("a").get_text()))[0]
if bug_level=="Critical":
bug_level="High"
elif bug_level=="Important":
bug_level=" Medium"
elif bug_level=="Moderate":
bug_level="Low"
db.get_data.insert(title=a[i].find("a").get_text(),
get_from='redhat',get_url=geturl,get_time=now,
body='',data_condition=condition[0],bug_num=
bug_num,bug_level=bug_level)
print a[i].find("a").get_text()
break
else:
break_flag = "yes"
print "redhat no new isuse"
break
if break_flag == "yes":
break


except Exception as e:
print e

except Exception as e:
pass
print "redhat finish in " +str(datetime.datetime.now()) +"\n"


from datetime import timedelta as timed
from gluon.scheduler import Scheduler
scheduler = Scheduler(db, dict(
mission5=redhat
)
)
scheduler.queue_task('mission5', 
start_time=request.now,  # datetime
stop_time=None,#request.now+timed(seconds=30),  # datetime
timeout = 90,  # seconds
period=60,  # seconds
immediate=True,
repeats=1
)
my script can normal run in controllers,but  in scheduler can't
and i want to control the quantity of scheduler_task,but it without stop 
create new task ,please help me

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to get teh last DB Field data

2017-11-15 Thread Leonel Câmara
What are you trying to do exactly? I mean, what's the objective here?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Is it possible to translate data in SQLFORM.grid?

2017-11-15 Thread Leonel Câmara
Yebach your code is wrong.

db.config.represent = lambda v, r: T(db.config[v].co_note)



Should be

db.config.co_note.represent = lambda v, r: T(v)



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQLFORM.grid custom form on validation, oncreate not triggered

2017-11-15 Thread Yebach
Hello

I have a custom form from SQLFORM.grid. After clicking the submit button 
onvalidation or oncreate funciton are not triggered - although some fields 
are validated, but that is even before the my_processing_form function 
there is no redirect after submit and the record is not inserted/updated in 
the database. I used the same principle with some other functions and views 
and there it works fine, but I have no idea why at this one the on validate 
is not triggered.
If anyone sees  the error please let me know

Here is my function

def shifts():
user = auth.user_id
org = db(db.auth_user.id == 
user).select(db.auth_user.organization)[0]["organization"]

db.workers.w_user.default = user
db.workers.w_organization.default = org
#Naredimo še grid za šifrant turnusov
db.shifts.sh_organization.default = org

query_shifts = ((db.shifts.sh_organization == org) & (db.shifts.sh_status 
== 1))
query_inactive = db((db.shifts.sh_organization == org) & 
(db.shifts.sh_status == 100)).select().as_list()
# print query_inactive

###V kolikor uporabnik naredi turnus ki je že ampak je 
arhiviran/deaktiviran ga je potrebno na to opozorit
##Določimo da ne more bit za istga userja dvakrat isti turnus

# db.shifts.sh_code.requires=IS_NOT_IN_DB(db(db.shifts.sh_organization == 
org),'shifts.sh_code')

# najprej popravmo definicijo tabele

fields_shifts = (
db.shifts.sh_code,
db.shifts.sh_name,
db.shifts.sh_color,
db.shifts.sh_category,
db.shifts.sh_start1,
db.shifts.sh_end1,
db.shifts.sh_length1,
db.shifts.sh_start2,
db.shifts.sh_end2,
db.shifts.sh_length2,
db.shifts.sh_duration1,
# db.shifts.sh_start3,
# db.shifts.sh_end3,
# db.shifts.sh_start4,
# db.shifts.sh_end4,
# db.shifts.sh_start5,
# db.shifts.sh_end5,
db.shifts.sh_note)

db.shifts.sh_organization.readable = False
db.shifts.sh_organization.writable = False
db.shifts.sh_organization.editable = False

# db.shifts.sh_code.editable = db.shifts.sh_code.writable = False

# db.shifts.sh_duration.writable = False

db.shifts.sh_duration1.readable = db.shifts.sh_duration1.writable = False
db.shifts.sh_start3.readable = db.shifts.sh_start3.writable = False
db.shifts.sh_end3.readable = db.shifts.sh_end3.writable = False
db.shifts.sh_length3.readable = db.shifts.sh_length3.writable = False
db.shifts.sh_start4.readable = db.shifts.sh_start4.writable = False
db.shifts.sh_length4.readable = db.shifts.sh_length4.writable = False
db.shifts.sh_end4.readable = db.shifts.sh_end4.writable = False
db.shifts.sh_start5.readable = db.shifts.sh_start5.writable = False
db.shifts.sh_length5.readable = db.shifts.sh_length5.writable = False
db.shifts.sh_end5.readable = db.shifts.sh_end5.writable = False


db.shifts.sh_code.widget = SQLFORM.widgets.string.widget
db.shifts.sh_name.widget = SQLFORM.widgets.string.widget
db.shifts.sh_note.widget = SQLFORM.widgets.string.widget
db.shifts.partner_id.widget = SQLFORM.widgets.integer.widget
#db.shifts.sh_category.widget = SQLFORM.widgets.integer.widget
#db.shifts.sh_start1 = SQLFORM.widgets.time.widget
#db.shifts.sh_start1 = SQLFORM.widgets.timewidget.widget

db.shifts.sh_code.requires = [IS_NOT_IN_DB(db((db.shifts.sh_organization == 
org)&(db.shifts.sh_status != 250)), 'shifts.sh_code',
   error_message=T('Shift with this 
code already exist. Follow the link in upper right corner'))]

db.shifts.sh_name.requires = [IS_NOT_EMPTY(error_message=T('Missing shift 
name'))]
db.shifts.sh_color.requires = [IS_NOT_EMPTY(error_message=T('Missing shift 
color'))]
db.shifts.sh_start1.requires = [IS_NOT_EMPTY(error_message=T('Missing start 
time of the shift'))]
db.shifts.sh_end1.requires = [IS_NOT_EMPTY(error_message=T('Missing end 
time of the shift'))]
# db.shifts.sh_category.requires = [IS_NOT_EMPTY(error_message=T("""Missing 
shift category.1 – Morning, 11- Afternoon, 21 – Night
# 101 – All 
day,121 – All night,201 – Day split"""))]
db.shifts.partner_id.requires = 
IS_EMPTY_OR(IS_NOT_IN_DB(db((db.shifts.sh_organization == org)
& (db.shifts.sh_status != 
250)
& (db.shifts.partner_id == 
request.vars.partner_id)
& (db.shifts.partner_id >= 
0)), db.shifts.partner_id,
  error_message=T('There is a shift 
with the same partned ID.')))



links = [lambda row: A('', _class='glyphicon glyphicon 
glyphicon-remove-sign',
   callback=URL('settings', 'deactivate',
v

Re: [web2py] Re: How to get teh last DB Field data

2017-11-15 Thread Maurice Waka
Something close to this:
https://www.daniweb.com/programming/software-development/threads/310925/refresh-data-base-after-inserting-records

On 15 Nov 2017 1:33 PM, "Leonel Câmara"  wrote:

> What are you trying to do exactly? I mean, what's the objective here?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/ERqZpKfZgyc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web2py and machine learning - scikit-learn

2017-11-15 Thread Pierre
Is there a reliable way to determine whether or not a library is 
thread-safe ?

what's the web2py method for locking ?(module: thread/threading ? what 
kind of lock with what option: blocking/non-blocking) ?)

thanks




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to get teh last DB Field data

2017-11-15 Thread Leonel Câmara
You probably have some bug in your code. Is the list of messages in a HTML 
element with id="target"?  
  
If you want put the APP here I'll fix it.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to get teh last DB Field data

2017-11-15 Thread Anthony


> controller/default/index.py
> ...
> form =SQLFORM(Post, formstyle='table3cols')
> if request.vars.message:
> db.post.insert(message=request.vars.message)
> pass
> String = ''
> for s in db(db.post.author==auth.user.id).select(db.post.ALL):
> String = s.message
>

First, you don't need to loop through all the records just to get the last 
one -- instead, just index with [-1]. Or better yet, have the db sort in 
reverse order and use limitby=(0, 1) to get the last record.

Anyway, in the code above, the final value of String should be the message 
from the record inserted above. Perhaps the error is somewhere in the code 
you haven't shown (e.g., the view code).

Also, not sure what you mean by "refreshing the database".

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How to get teh last DB Field data

2017-11-15 Thread Maurice Waka
*controller*
@auth.requires_login()
def view_searches():
form = SQLFORM(Post)
if form.process().accepted:
#pass
response.flash = 'done'
if request.vars.message:
db.post.insert(message = request.vars.message)
db.commit()
quiz = db(db.post.author == auth.user.id).select(db.post.ALL,
limitby=(1,0))
return dict(form =form, quiz=quiz)

N/B
The several functions that will need to use 'quiz' string to process data.
I was posting it to html to view if latest string matches the one on db as
previously described. Otherwise, the functions will pick the string from
the updated db with the latest string as follows:

def Search_name():
  db = current.db
  auth = Auth(db, hmac_key=Auth.get_or_create_key())
  auth.define_tables()
  name  = [r.message for r in db(db.post.author == auth.user.id
).select(db.post.ALL)][-1]
  return name


*the view.html*
See www.sololearn.com from where i borrowed this html code.

{{extend "layout.html"}}




https://code.jquery.com/jquery-3.1.1.js";>

Page Title


Chat Bot

Original



SEND





* {
   margin: 0px;
   user-select: none;
   -webkit-user-select: none;
   -moz-user-select: none;
}
body {
margin: 0px;
height:400px;
bottom:0;
}
#user {
width: 100vw;
position: fixed;
left: 0px;
bottom: 0px;
display: block;
background-color: #EEE;
white-space: nowrap;
height:105px;
}
#msgbox {
   width: calc(80% - 12px);
   min-height: 25px;
   max-height: 35px;
   padding: 5px;
   outline: none;
   border: solid 1px #AAA;
   display: inline-block;
   vertical-align: center;
   float: left;
   background-color: #FFF;
   border-radius: 25px;
   resize: none;
   margin: 0px;
   word-wrap:break-all;
}
#send {
   width: 20vw;
   height: 35px;
   display: inline-block
   outline: none;
   border: none;
   color: #FFF;
   background-color: #00F;
   float: left;
   border-radius: 25px;
   padding: 0px;
   cursor: pointer;
   margin: 0px;
}
#send:active {
   background-color: #00A;
   outline: none;
}
#header {
   display: flex;
   justify-content: left;
   align-items: center;
   width: calc(100% - 30px);
   height: 20px;
   padding: 15px;
   color: #FFF;
   font-size: 200%;
   font-weight: bolder;
   background-color: #00F;
   position: fixed;
   font-family: arial;
}
#messages {
   display: block;
   width: 100vw;
   height: calc(100% - 87px);
   background-color: #EEE;
   position: fixed;
   top: 50px;
   left: 0px;
   overflow: auto;
   overflow-x: hidden;
   overflow-y: auto;
}
.left {
   text-align: left;
   /*
   display: block;
   */
}
.right {
   text-align: right;
   /*
   display: block;
   */
}
.incoming {
   background-color: #FFF;
   color: #000;
   border: solid 1px #AAA;
}
.outgoing {
   background-color: #00F;
   color: #FFF;
}
.section {
   display: block;
   width: calc(100% - 30px);
   padding-left: 15px;
   padding-right: 15px;
   margin-top: 7.5px;
   margin-bottom: 7.5px;
}
.message {
   display: inline-flex;
   justify-content: left;
   align-items: center;
   border-radius: 25px;
   padding: 10px;
   font-size: 10pt;
}
input:first {
   color: #F00;
}
.incoming:active {
   background-color: #EEE;
}
.outgoing:active {
   background-color: #00A;
}
* {
   outline: none;
   tap-highlight: none;
   -webkit-tap-highlight: none;
   -webkit-tap-highlight-color: none;
   -moz-tap-highlight: none;
   -moz-tap-highlight-color: none;
   -khtml-tap-highlight: none;
   -khtml-tap-highlight-color: none;
}
a {
   display: block;
   text-align: center;
}



$(function(){
var commands = {
   "random":"var rand = (Math.floor(Math.random() * 10));
incoming(rand);",
   "commands":"var objstr = JSON.stringify(commands); objstr =
JSON.stringify(commands, null, 4); incoming(objstr)"
}
var responseSys = {
"hi":"Hello There!",
"bye":"GoodBye!"
};
function cmd(name, action){
   commands[name] = action;
}
function outgoing(text){
var newMsg = "
" + text + "
"; $("#messages").append(newMsg); } function incoming(text){ var newMsg = "
" +

Re: [web2py] Re: How to get teh last DB Field data

2017-11-15 Thread Maurice Waka
About db refresh,
when i go to the database administration page in the app, and open the
post.db page, i have to manually refresh the page to see the latest
inserted value which does not match with the returned value as explained.
That's why i was thinking of a way to refresh the db after the input and
insert to the Field, perhaps to get the last inserted record.
Regards

On Wed, Nov 15, 2017 at 5:46 PM, Maurice Waka  wrote:

> *controller*
> @auth.requires_login()
> def view_searches():
> form = SQLFORM(Post)
> if form.process().accepted:
> #pass
> response.flash = 'done'
> if request.vars.message:
> db.post.insert(message = request.vars.message)
> db.commit()
> quiz = db(db.post.author == auth.user.id).select(db.post.ALL,
> limitby=(1,0))
> return dict(form =form, quiz=quiz)
>
> N/B
> The several functions that will need to use 'quiz' string to process data.
> I was posting it to html to view if latest string matches the one on db as
> previously described. Otherwise, the functions will pick the string from
> the updated db with the latest string as follows:
>
> def Search_name():
>   db = current.db
>   auth = Auth(db, hmac_key=Auth.get_or_create_key())
>   auth.define_tables()
>   name  = [r.message for r in db(db.post.author == auth.user.id
> ).select(db.post.ALL)][-1]
>   return name
>
>
> *the view.html*
> See www.sololearn.com from where i borrowed this html code.
>
> {{extend "layout.html"}}
>
> 
> 
> 
> https://code.jquery.com/jquery-3.1.1.js";>
> 
> Page Title
> 
> 
> Chat Bot
> 
> 
> Original
> 
> 
>  placeholder="Type a message..." />
> SEND
> 
> 
> 
>
> 
> * {
>margin: 0px;
>user-select: none;
>-webkit-user-select: none;
>-moz-user-select: none;
> }
> body {
> margin: 0px;
> height:400px;
> bottom:0;
> }
> #user {
> width: 100vw;
> position: fixed;
> left: 0px;
> bottom: 0px;
> display: block;
> background-color: #EEE;
> white-space: nowrap;
> height:105px;
> }
> #msgbox {
>width: calc(80% - 12px);
>min-height: 25px;
>max-height: 35px;
>padding: 5px;
>outline: none;
>border: solid 1px #AAA;
>display: inline-block;
>vertical-align: center;
>float: left;
>background-color: #FFF;
>border-radius: 25px;
>resize: none;
>margin: 0px;
>word-wrap:break-all;
> }
> #send {
>width: 20vw;
>height: 35px;
>display: inline-block
>outline: none;
>border: none;
>color: #FFF;
>background-color: #00F;
>float: left;
>border-radius: 25px;
>padding: 0px;
>cursor: pointer;
>margin: 0px;
> }
> #send:active {
>background-color: #00A;
>outline: none;
> }
> #header {
>display: flex;
>justify-content: left;
>align-items: center;
>width: calc(100% - 30px);
>height: 20px;
>padding: 15px;
>color: #FFF;
>font-size: 200%;
>font-weight: bolder;
>background-color: #00F;
>position: fixed;
>font-family: arial;
> }
> #messages {
>display: block;
>width: 100vw;
>height: calc(100% - 87px);
>background-color: #EEE;
>position: fixed;
>top: 50px;
>left: 0px;
>overflow: auto;
>overflow-x: hidden;
>overflow-y: auto;
> }
> .left {
>text-align: left;
>/*
>display: block;
>*/
> }
> .right {
>text-align: right;
>/*
>display: block;
>*/
> }
> .incoming {
>background-color: #FFF;
>color: #000;
>border: solid 1px #AAA;
> }
> .outgoing {
>background-color: #00F;
>color: #FFF;
> }
> .section {
>display: block;
>width: calc(100% - 30px);
>padding-left: 15px;
>padding-right: 15px;
>margin-top: 7.5px;
>margin-bottom: 7.5px;
> }
> .message {
>display: inline-flex;
>justify-content: left;
>align-items: center;
>border-radius: 25px;
>padding: 10px;
>font-size: 10pt;
> }
> input:first {
>color: #F00;
> }
> .incoming:active {
>background-color: #EEE;
> }
> .outgoing:active {
>background-color: #00A;
> }
> * {
>outline: none;
>tap-highlight: none;
>-webkit-tap-highlight: none;
>-webkit-tap-highlight-color: none;
>-moz-tap-highlight: none;
>-moz-tap-highlight-color: none;
>-khtml-tap-highlight: none;
>-khtml-tap-highlight-color: none;
> }
> a {
>

[web2py] Re: SQLFORM.grid custom form on validation, oncreate not triggered

2017-11-15 Thread Anthony
The oncreate function is pointless because the only thing it does is 
conditionally alter the form errors and vars, but then it redirects -- so 
nothing happens with the altered form errors and vars (the redirect results 
in a new request, so nothing from the current request is preserved).

You onvalidation function should be getting called as expected. If you are 
not seeing the validations you are expecting, likely there are some errors 
in the code.

Also, in the conditional block near the end of your code, you set 
session.flash, but the code then does a return rather than a redirect. 
session.flash is typically set right before a redirect because it doesn't 
get displayed until the next request (when a new request comes in, it 
checks for session.flash and transfers it to response.flash).

Anthony

On Wednesday, November 15, 2017 at 6:55:47 AM UTC-5, Yebach wrote:
>
> Hello
>
> I have a custom form from SQLFORM.grid. After clicking the submit button 
> onvalidation or oncreate funciton are not triggered - although some fields 
> are validated, but that is even before the my_processing_form function 
> there is no redirect after submit and the record is not inserted/updated in 
> the database. I used the same principle with some other functions and views 
> and there it works fine, but I have no idea why at this one the on validate 
> is not triggered.
> If anyone sees  the error please let me know
>
> Here is my function
>
> def shifts():
> user = auth.user_id
> org = db(db.auth_user.id == 
> user).select(db.auth_user.organization)[0]["organization"]
>
> db.workers.w_user.default = user
> db.workers.w_organization.default = org
> #Naredimo še grid za šifrant turnusov
> db.shifts.sh_organization.default = org
>
> query_shifts = ((db.shifts.sh_organization == org) & (db.shifts.sh_status 
> == 1))
> query_inactive = db((db.shifts.sh_organization == org) & 
> (db.shifts.sh_status == 100)).select().as_list()
> # print query_inactive
>
> ###V kolikor uporabnik naredi turnus ki je že ampak je 
> arhiviran/deaktiviran ga je potrebno na to opozorit
> ##Določimo da ne more bit za istga userja dvakrat isti turnus
>
> # db.shifts.sh_code.requires=IS_NOT_IN_DB(db(db.shifts.sh_organization == 
> org),'shifts.sh_code')
>
> # najprej popravmo definicijo tabele
>
> fields_shifts = (
> db.shifts.sh_code,
> db.shifts.sh_name,
> db.shifts.sh_color,
> db.shifts.sh_category,
> db.shifts.sh_start1,
> db.shifts.sh_end1,
> db.shifts.sh_length1,
> db.shifts.sh_start2,
> db.shifts.sh_end2,
> db.shifts.sh_length2,
> db.shifts.sh_duration1,
> # db.shifts.sh_start3,
> # db.shifts.sh_end3,
> # db.shifts.sh_start4,
> # db.shifts.sh_end4,
> # db.shifts.sh_start5,
> # db.shifts.sh_end5,
> db.shifts.sh_note)
>
> db.shifts.sh_organization.readable = False
> db.shifts.sh_organization.writable = False
> db.shifts.sh_organization.editable = False
>
> # db.shifts.sh_code.editable = db.shifts.sh_code.writable = False
>
> # db.shifts.sh_duration.writable = False
>
> db.shifts.sh_duration1.readable = db.shifts.sh_duration1.writable = False
> db.shifts.sh_start3.readable = db.shifts.sh_start3.writable = False
> db.shifts.sh_end3.readable = db.shifts.sh_end3.writable = False
> db.shifts.sh_length3.readable = db.shifts.sh_length3.writable = False
> db.shifts.sh_start4.readable = db.shifts.sh_start4.writable = False
> db.shifts.sh_length4.readable = db.shifts.sh_length4.writable = False
> db.shifts.sh_end4.readable = db.shifts.sh_end4.writable = False
> db.shifts.sh_start5.readable = db.shifts.sh_start5.writable = False
> db.shifts.sh_length5.readable = db.shifts.sh_length5.writable = False
> db.shifts.sh_end5.readable = db.shifts.sh_end5.writable = False
>
>
> db.shifts.sh_code.widget = SQLFORM.widgets.string.widget
> db.shifts.sh_name.widget = SQLFORM.widgets.string.widget
> db.shifts.sh_note.widget = SQLFORM.widgets.string.widget
> db.shifts.partner_id.widget = SQLFORM.widgets.integer.widget
> #db.shifts.sh_category.widget = SQLFORM.widgets.integer.widget
> #db.shifts.sh_start1 = SQLFORM.widgets.time.widget
> #db.shifts.sh_start1 = SQLFORM.widgets.timewidget.widget
>
> db.shifts.sh_code.requires = [IS_NOT_IN_DB(db((db.shifts.sh_organization 
> == org)&(db.shifts.sh_status != 250)), 'shifts.sh_code',
>error_message=T('Shift with 
> this code already exist. Follow the link in upper right corner'))]
>
> db.shifts.sh_name.requires = [IS_NOT_EMPTY(error_message=T('Missing shift 
> name'))]
> db.shifts.sh_color.requires = [IS_NOT_EMPTY(error_message=T('Missing 
> shift color'))]
> db.shifts.sh_start1.requires = [IS_NOT_EMPTY(error_message=T('Missing 
> start time of the shift')

Re: [web2py] Re: How to get teh last DB Field data

2017-11-15 Thread Maurice Waka
addendum:

Post = db.define_table('post',
   Field('author', 'reference auth_user',
default=auth.user_id, writable=False, readable=False),
   Field('message', 'text', requires=IS_NOT_EMPTY(),
default ='', notnull=False),
   auth.signature
   )

On Wed, Nov 15, 2017 at 5:51 PM, Maurice Waka  wrote:

> About db refresh,
> when i go to the database administration page in the app, and open the
> post.db page, i have to manually refresh the page to see the latest
> inserted value which does not match with the returned value as explained.
> That's why i was thinking of a way to refresh the db after the input and
> insert to the Field, perhaps to get the last inserted record.
> Regards
>
> On Wed, Nov 15, 2017 at 5:46 PM, Maurice Waka 
> wrote:
>
>> *controller*
>> @auth.requires_login()
>> def view_searches():
>> form = SQLFORM(Post)
>> if form.process().accepted:
>> #pass
>> response.flash = 'done'
>> if request.vars.message:
>> db.post.insert(message = request.vars.message)
>> db.commit()
>> quiz = db(db.post.author == auth.user.id).select(db.post.ALL,
>> limitby=(1,0))
>> return dict(form =form, quiz=quiz)
>>
>> N/B
>> The several functions that will need to use 'quiz' string to process
>> data. I was posting it to html to view if latest string matches the one on
>> db as previously described. Otherwise, the functions will pick the string
>> from the updated db with the latest string as follows:
>>
>> def Search_name():
>>   db = current.db
>>   auth = Auth(db, hmac_key=Auth.get_or_create_key())
>>   auth.define_tables()
>>   name  = [r.message for r in db(db.post.author == auth.user.id
>> ).select(db.post.ALL)][-1]
>>   return name
>>
>>
>> *the view.html*
>> See www.sololearn.com from where i borrowed this html code.
>>
>> {{extend "layout.html"}}
>>
>> 
>> 
>> 
>> https://code.jquery.com/jquery-3.1.1.js";>
>> 
>> Page Title
>> 
>> 
>> Chat Bot
>> 
>> Orig
>> inal
>> 
>> 
>> > placeholder="Type a message..." />
>> SEND
>> 
>> 
>> 
>>
>> 
>> * {
>>margin: 0px;
>>user-select: none;
>>-webkit-user-select: none;
>>-moz-user-select: none;
>> }
>> body {
>> margin: 0px;
>> height:400px;
>> bottom:0;
>> }
>> #user {
>> width: 100vw;
>> position: fixed;
>> left: 0px;
>> bottom: 0px;
>> display: block;
>> background-color: #EEE;
>> white-space: nowrap;
>> height:105px;
>> }
>> #msgbox {
>>width: calc(80% - 12px);
>>min-height: 25px;
>>max-height: 35px;
>>padding: 5px;
>>outline: none;
>>border: solid 1px #AAA;
>>display: inline-block;
>>vertical-align: center;
>>float: left;
>>background-color: #FFF;
>>border-radius: 25px;
>>resize: none;
>>margin: 0px;
>>word-wrap:break-all;
>> }
>> #send {
>>width: 20vw;
>>height: 35px;
>>display: inline-block
>>outline: none;
>>border: none;
>>color: #FFF;
>>background-color: #00F;
>>float: left;
>>border-radius: 25px;
>>padding: 0px;
>>cursor: pointer;
>>margin: 0px;
>> }
>> #send:active {
>>background-color: #00A;
>>outline: none;
>> }
>> #header {
>>display: flex;
>>justify-content: left;
>>align-items: center;
>>width: calc(100% - 30px);
>>height: 20px;
>>padding: 15px;
>>color: #FFF;
>>font-size: 200%;
>>font-weight: bolder;
>>background-color: #00F;
>>position: fixed;
>>font-family: arial;
>> }
>> #messages {
>>display: block;
>>width: 100vw;
>>height: calc(100% - 87px);
>>background-color: #EEE;
>>position: fixed;
>>top: 50px;
>>left: 0px;
>>overflow: auto;
>>overflow-x: hidden;
>>overflow-y: auto;
>> }
>> .left {
>>text-align: left;
>>/*
>>display: block;
>>*/
>> }
>> .right {
>>text-align: right;
>>/*
>>display: block;
>>*/
>> }
>> .incoming {
>>background-color: #FFF;
>>color: #000;
>>border: solid 1px #AAA;
>> }
>> .outgoing {
>>background-color: #00F;
>>color: #FFF;
>> }
>> .section {
>>display: block;
>>width: calc(100% - 30px);
>>padding-left: 15px;
>>padding-right: 15px;
>>margin-top: 7.5px;
>>margin-bottom: 7.5px;
>> }
>> .message {
>>display: inline-flex;
>>justify-content: left;
>>align-items: center;
>>border-radius: 25px

[web2py] Re: scheduler can't normal run my script

2017-11-15 Thread Anthony
How are you starting the scheduler workers? Typically the scheduler is run 
in the context of a web2py app environment, so the database and tasks are 
defined in a web2py app.

To run the scheduler outside of the web2py context, see 
https://github.com/web2py/web2py/blob/c9fd0fd71e770c1a367b45ad5def5bd2c6fd7115/gluon/scheduler.py#L1637.
 
You'll need to specify the DB URI, a folder where the DAL model definition 
metadata files will be stored, and a file where the tasks are defined.

Anthony

On Wednesday, November 15, 2017 at 4:04:15 AM UTC-5, yytry...@gmail.com 
wrote:
>
> i write a scripy to get some information and use scheduler to auto ,but 
> scheduler is display FAILED,this is my script
>
> def redhat():
> bug_num =''
> try:
> try:
> url = 'https://access.redhat.com/security/vulnerabilities'
> rea = requests.get(url)
> rea.encoding = 'utf-8'
> html = BeautifulSoup(rea.text,"html.parser")
> a= html.find("tbody").find_all("tr")
> try:
> indatabase = db(db.get_data.get_from == "redhat").select()
> if indatabase:
> indatabase=db(db.get_data.get_from == "redhat").select
> (
> db.get_data.title,orderby=~db.get_data.get_time,
> limitby=(0,5))
> else:
> indatabase=['1']
> except BaseException as e:
> print e
> for i in range(len(a)):
> for j in indatabase:
> break_flag ='no'
> if a[i].find("a").get_text() != j.title:
> geturl = 'https://access.redhat.com'+ str(a[i].
> find("a")).split('"')[1]
> bug_level = a[i].find("div","field-type-list-text"
> ).get_text().strip()
> if re.findall(u'CVE\-[0-9]{4,}\-[0-9]{4,}',str(a[i
> ].find("a").get_text())):
> bug_num = re.findall(u
> 'CVE\-[0-9]{4,}\-[0-9]{4,}',str(a[i].find("a").get_text()))[0]
> if bug_level=="Critical":
> bug_level="High"
> elif bug_level=="Important":
> bug_level=" Medium"
> elif bug_level=="Moderate":
> bug_level="Low"
> db.get_data.insert(title=a[i].find("a").get_text
> (),get_from='redhat',get_url=geturl,get_time=now,
> body='',data_condition=condition[0],bug_num=
> bug_num,bug_level=bug_level)
> print a[i].find("a").get_text()
> break
> else:
> break_flag = "yes"
> print "redhat no new isuse"
> break
> if break_flag == "yes":
> break
>
>
> except Exception as e:
> print e
> 
> except Exception as e:
> pass
> print "redhat finish in " +str(datetime.datetime.now()) +"\n"
>
>
> from datetime import timedelta as timed
> from gluon.scheduler import Scheduler
> scheduler = Scheduler(db, dict(
> mission5=redhat
> )
> )
> scheduler.queue_task('mission5', 
> start_time=request.now,  # datetime
> stop_time=None,#request.now+timed(seconds=30),  # datetime
> timeout = 90,  # seconds
> period=60,  # seconds
> immediate=True,
> repeats=1
> )
> my script can normal run in controllers,but  in scheduler can't
> and i want to control the quantity of scheduler_task,but it without stop 
> create new task ,please help me
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Web2Py + VueJS SPA (Webpack)

2017-11-15 Thread Carlos A. Armenta Castro
Hi José,

I'm not in a hurry, but I will appreciate so much your help.

Thank you!

P.S. Your recipe with the Webpack proxyTable is working like a charm in my
dev server. 😅

> lso, in webpack.config.babel.js configuration file ,  if you add
>
>
>   devServer: {
> host: '127.0.0.1',
> port: 8001,
> historyApiFallback: false,
> noInfo: true,
> proxy: {
>   '/yourapp/api/*': {
> target: 'http://127.0.0.1:8080',
> secure: false
> // changeOrigin: true,
> // pathRewrite: { '^/api': '' }
>   }
> },
>   },
>

On Tue, Nov 14, 2017 at 12:58 PM, José Luis Redrejo 
wrote:

> Carlos, by the way, if you are not in a hurry I can prepare a proof of
> concept this weekend. I just can tell it really works because I am using it
> in a system in production.
>
> Of course, that's the develop setup, once develop is done in production we
> use nginx-uwsgi only, but in that case there's no cors problem as
> everything runs in the same server.
>
>
> The only thing I miss in web2py (waving Massimo ;) ) is having something
> like http://pyramid-webpack.readthedocs.io/en/latest/
>
> It would allow us to write in the view  controller/function.html something
> like
>
> 
>
> 

[web2py] Re: Failing calculate the average

2017-11-15 Thread Anthony
 
>
> {{
> average=0for report in form:
> perc=(float(report.marks)/float(report.total))*float(100)if perc>=75:
> grade='A'elif perc>=65:
> grade='B'elif perc>=55:
> grade='C'elif perc>=45:
> grade='D'
>
> This is where I'm attempting to calculate the average
>
> average+=perc
> average2=int(average/7)}}
> {{pass}}
>
>
Looks like the {{pass}} immediately above closes the if/elif block, which 
means the two lines of code dealing with average and average2 only get 
executed in the "elif perc >= 45" block. That means average2 wouldn't even 
be defined otherwise, so I would expect you would be getting errors later 
in the code whenever there isn't at least one D in the list of grades.

Also, there is no reason to calculate average2 inside the for loop -- you 
only need to calculate it once after looping over all the records.

Finall, why not name the variables something like "total" and "average" 
instead of "average" (which is not really an average) and "average2"?

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Janrain recently broken (and how to fix)

2017-11-15 Thread Anthony
If anyone is using web2py's Janrain integration, it looks like Janrain 
recently made a change that breaks the web2py code. I submitted a pull 
request to fix it, but in the meantime, a temporary workaround is to add 
the following in the user() function (before the call to auth()):

if request.post_vars.token:
del request.get_vars.token

The problem is that Janrain is now passing the token to the web2py URL via 
both a POST variable and the query string. One of those two must be deleted 
before calling auth() for the current web2py code to work.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Failing calculate the average

2017-11-15 Thread mostwanted
U were right man, i calculated my average right below the {{pass}} and now 
it is able to increment and do the average of course i changed the 
variables to total and average.

Thanks alot Tony

On Wednesday, November 15, 2017 at 5:36:19 PM UTC+2, Anthony wrote:
>
> {{
>> average=0for report in form:
>> perc=(float(report.marks)/float(report.total))*float(100)if perc>=75:
>> grade='A'elif perc>=65:
>> grade='B'elif perc>=55:
>> grade='C'elif perc>=45:
>> grade='D'
>>
>> This is where I'm attempting to calculate the average
>>
>> average+=perc
>> average2=int(average/7)}}
>> {{pass}}
>>
>>
> Looks like the {{pass}} immediately above closes the if/elif block, which 
> means the two lines of code dealing with average and average2 only get 
> executed in the "elif perc >= 45" block. That means average2 wouldn't even 
> be defined otherwise, so I would expect you would be getting errors later 
> in the code whenever there isn't at least one D in the list of grades.
>
> Also, there is no reason to calculate average2 inside the for loop -- you 
> only need to calculate it once after looping over all the records.
>
> Finall, why not name the variables something like "total" and "average" 
> instead of "average" (which is not really an average) and "average2"?
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.