Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
self.board = "na-satbus-3c0-gcc"
self.arch = "ARM"
self.cpu = "stm32f405"
self.binfiletype = "ELF"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27)
}
def __init__(self):
self.board = "stm32f407-disco-gcc"
self.arch = "ARM"
self.cpu = "stm32f407"
self.binfiletype = "ELF"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27),
'opt' : Pin(name = 'opt', number = 22) # optional
}
def __init__(self):
self.board = "msp430f5529-gcc"
self.arch = "MSP430"
self.cpu = "msp430f5529"
self.binfiletype = "ELF"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27),
'opt' : Pin(name = 'opt', number = 22) # optional
}
def __init__(self):
self.board = "noboard"
self.arch = "noarch"
self.cpu = "nocpu"
self.binfiletype = "nobinfile"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27),
'opt' : Pin(name = 'opt', number = 22)
}
def __init__(self):
self.board = "pyboard-gcc"
self.arch = "ARM"
self.cpu = "stm32f405"
self.binfiletype = "BIN"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27),
'prg' : Pin(name = 'prg', number = 18),
'opt' : Pin(name = 'opt', number = 22)
}
def do_delegation(self, cmd, args):
load_plugins()
# project precondition
proj_path = registry.pathfor(cmd)
if proj_path is not None:
os.chdir(proj_path)
cmd = args[0]
args = args[1:]
if '-' in cmd:
cmd, newargs = cmd.split('-', 1)
args = [newargs, ] + args
comcls = command.get(cmd) or command.get('help')
try:
if comcls:
comobj = comcls(args)
if comobj.is_relevant():
comobj._execute()
else:
helpcls = command.get('help')
helpobj = helpcls((cmd,))
helpobj._execute()
print "\n'%s %s' command not relevant here." % (cmd, ' '.join(args).strip())
else:
self.do_default()
except KeyboardInterrupt:
print "\n"
pass
proj_path = registry.pathfor(cmd)
if proj_path is not None:
os.chdir(proj_path)
cmd = args[0]
args = args[1:]
if '-' in cmd:
cmd, newargs = cmd.split('-', 1)
args = [newargs, ] + args
comcls = command.get(cmd) or command.get('help')
try:
if comcls:
comobj = comcls(args)
if comobj.is_relevant():
comobj._execute()
else:
helpcls = command.get('help')
helpobj = helpcls((cmd,))
helpobj._execute()
print "\n'%s %s' command not relevant here." % (cmd, ' '.join(args).strip())
else:
self.do_default()
except KeyboardInterrupt:
print "\n"
pass
def do_delegation(self, cmd, args):
load_plugins()
# project precondition
proj_path = registry.pathfor(cmd)
if proj_path is not None:
os.chdir(proj_path)
cmd = args[0]
args = args[1:]
if '-' in cmd:
cmd, newargs = cmd.split('-', 1)
args = [newargs, ] + args
comcls = command.get(cmd) or command.get('help')
try:
if comcls:
comobj = comcls(args)
if comobj.is_relevant():
comobj._execute()
else:
helpcls = command.get('help')
helpobj = helpcls((cmd,))
if choices:
return choices
# we want commands to complete before
# project names, so if we don't return any
# choices above, complete a project name now
# if we're completing the first argument
if nargs == 1:
if proj_path is not None:
return os.path.basename(proj_path)
# # # # # # # #
# sub-commands
elif nargs == off + 1:
# get our parent command
com = args[off-1]
# get its class
comcls = command.get(com)
# if it is a delegate command
if hasattr(comcls, 'get_subcommands'):
# get partial subcommand name if user has typed anything
# or else use empty string to complete all
subcom = args[off] if len(args) == off+1 else ''
# get a list of the parent command's subcommands
subcom_choices = comcls.get_subcommands()
# if there are any subcommands
if subcom_choices:
# clean subcommand names (they use command-subcommand format)
choices = [k.split('-')[-1] for k in subcom_choices]
# return the subcommands that start with the partial subcommand name
return " ".join([c for c in choices if c.startswith(subcom)])
# return nothing
return ""
if interval == 'month':
data_from = datetime.datetime.now() - datetime.timedelta(days=30)
elif interval == 'lastday':
data_from = datetime.datetime.now() - datetime.timedelta(days=1)
elif interval == 'lastweek':
data_from = datetime.datetime.now() - datetime.timedelta(days=7)
elif interval == 'lasteigth':
data_from = datetime.datetime.now() - datetime.timedelta(hours=8)
start_from = mktime(data_from.timetuple())
post_list = Post.objects.filter(status=1)\
.extra(where=['timestamp>%s'], params=[start_from])\
.order_by('-cnt_like')
else:
post_list = Post.objects.filter(status=1)\
.order_by('-cnt_like')
paginator = Paginator(post_list, ROW_PER_PAGE)
try:
offset = int(request.GET.get('older', 1))
except ValueError:
offset = 1
try:
latest_items = paginator.page(offset)
except PageNotAnInteger:
latest_items = paginator.page(1)
except EmptyPage:
return HttpResponse(0)
if request.is_ajax():