prompt
large_stringlengths 72
9.34k
| completion
large_stringlengths 0
7.61k
|
---|---|
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
<|fim_middle|>
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | self.process_in_queue_data(data) |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
<|fim_middle|>
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | self.config_changed = True |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def <|fim_middle|>(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | __init__ |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def <|fim_middle|>(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | update_config |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def <|fim_middle|>(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | send_ping |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def <|fim_middle|>(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | exit_gracefully |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def <|fim_middle|>(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | unload |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def <|fim_middle|>(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | unload_callback |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def <|fim_middle|>(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | run |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def <|fim_middle|>(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | main |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def <|fim_middle|>(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | in_queue_handling |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def <|fim_middle|>(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | process_in_queue_data |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def <|fim_middle|>(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | log |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def <|fim_middle|>(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def __init__(self, name):
self.ack = False
<|fim▁end|> | set_config |
<|file_name|>APSync_module.py<|end_file_name|><|fim▁begin|># A template for APSync process based modules
from multiprocessing import Process, Event
import threading
import time
import signal, select
import traceback
import setproctitle
from APSyncFramework.utils.common_utils import PeriodicEvent
from APSyncFramework.utils.json_utils import ping, json_wrap_with_target
from APSyncFramework.utils.file_utils import read_config, write_config
class APModule(Process):
'''The base class for all modules'''
def __init__(self, in_queue, out_queue, name, description = None):
super(APModule, self).__init__()
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
self.daemon = True
self.config_list= [] # overwrite this list
self.config_changed = False
self.config = read_config()
self.start_time = time.time()
self.last_ping = None
self.needs_unloading = Event()
self.lock = threading.Lock()
self.in_queue = in_queue
self.out_queue = out_queue
self.name = name
self.ping = PeriodicEvent(frequency = 1.0/3.0, event = self.send_ping)
self.in_queue_thread = threading.Thread(target=self.in_queue_handling,
args = (self.lock,))
self.in_queue_thread.daemon = True
setproctitle.setproctitle(self.name)
if description is None:
self.description = "APSync {0} process".format(self.name)
else:
self.description = description
def update_config(self, config_list = []):
if len(config_list):
self.config_list = config_list
for (var_name, var_default) in self.config_list:
self.set_config(var_name, var_default)
if self.config_changed:
# TODO: send a msg to the webserver to update / reload the current page
self.log('At least one of your cloudsync settings was missing or has been updated, please reload the webpage if open.', 'INFO')
self.config_changed = False
config_on_disk = read_config()
for k in config_on_disk.keys():
if not k in self.config:
self.config[k] = config_on_disk[k]
write_config(self.config)
def send_ping(self):
self.out_queue.put_nowait(ping(self.name, self.pid))
def exit_gracefully(self, signum, frame):
self.unload()
def unload(self):
print self.name, 'called unload'
self.unload_callback()
self.needs_unloading.set()
def unload_callback(self):
''' overload to perform any module specific cleanup'''
pass
def run(self):
if self.in_queue_thread is not None:
self.in_queue_thread.start()
while not self.needs_unloading.is_set():
try:
self.main()
except:
print ("FATAL: module ({0}) exited while multiprocessing".format(self.name))
traceback.print_exc()
# TODO: logging here
print self.name, 'main finished'
def main(self):
pass
def in_queue_handling(self, lock=None):
while not self.needs_unloading.is_set():
(inputready,outputready,exceptready) = select.select([self.in_queue._reader],[],[],0.1)
for s in inputready:
while not self.in_queue.empty():
# drain the queue
data = self.in_queue.get_nowait()
if isinstance(data, Unload):
self.unload()
else:
# do something useful with the data...
self.process_in_queue_data(data)
self.ping.trigger()
print self.name, 'in queue finished'
def process_in_queue_data(self, data):
pass
def log(self, message, level = 'INFO'):
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
# NOTSET
self.out_queue.put_nowait(json_wrap_with_target({'msg':message, 'level':level}, target = 'logging'))
def set_config(self, var_name, var_default):
new_val = self.config.get(var_name, var_default)
try:
cur_val = self.config[var_name]
if new_val != cur_val:
self.config_changed = True
except:
self.config_changed = True
finally:
self.config[var_name] = new_val
return new_val
class Unload():
def <|fim_middle|>(self, name):
self.ack = False
<|fim▁end|> | __init__ |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)<|fim▁hole|>
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"<|fim▁end|> | |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
<|fim_middle|>
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)" |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
<|fim_middle|>
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))" |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
<|fim_middle|>
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))" |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
<|fim_middle|>
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)" |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
<|fim_middle|>
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)" |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
<|fim_middle|>
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)" |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
<|fim_middle|>
<|fim▁end|> | with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)" |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def <|fim_middle|>():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | test_list_of_representation |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def <|fim_middle|>():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | test_list_of_values_representation |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def <|fim_middle|>():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | test_list_of_repr_values_representation |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def <|fim_middle|>():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | test_list_of_len_representation |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def <|fim_middle|>():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | test_list_of_min_len_representation |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def <|fim_middle|>():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def test_list_of_min_max_len_representation():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | test_list_of_max_len_representation |
<|file_name|>test_list_of_representation.py<|end_file_name|><|fim▁begin|>from baby_steps import given, then, when
from district42 import represent, schema
def test_list_of_representation():
with given:
sch = schema.list(schema.bool)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.bool)"
def test_list_of_values_representation():
with given:
sch = schema.list(schema.int(1))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int(1))"
def test_list_of_repr_values_representation():
with given:
sch = schema.list(schema.str("banana"))
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.str('banana'))"
def test_list_of_len_representation():
with given:
sch = schema.list(schema.int).len(10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(10)"
def test_list_of_min_len_representation():
with given:
sch = schema.list(schema.int).len(1, ...)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, ...)"
def test_list_of_max_len_representation():
with given:
sch = schema.list(schema.int).len(..., 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(..., 10)"
def <|fim_middle|>():
with given:
sch = schema.list(schema.int).len(1, 10)
with when:
res = represent(sch)
with then:
assert res == "schema.list(schema.int).len(1, 10)"
<|fim▁end|> | test_list_of_min_max_len_representation |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)<|fim▁hole|> def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))<|fim▁end|> | self.client = None
self.is_super_user = True
|
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
<|fim_middle|>
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks) |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
<|fim_middle|>
def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def build_option_parser(self, description, version, argparse_kwargs=None):
<|fim_middle|>
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
<|fim_middle|>
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks) |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def main(argv=sys.argv[1:]):
<|fim_middle|>
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | return KanboardShell().run(argv) |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | sys.exit(main(sys.argv[1:])) |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def <|fim_middle|>(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | __init__ |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def <|fim_middle|>(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | build_option_parser |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def <|fim_middle|>(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def main(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | initialize_app |
<|file_name|>shell.py<|end_file_name|><|fim▁begin|># The MIT License (MIT)
#
# Copyright (c) 2016 Frederic Guillot
#
# 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.
from cliff import app
from cliff import commandmanager
from pbr import version as app_version
import sys
from kanboard_cli.commands import application
from kanboard_cli.commands import project
from kanboard_cli.commands import task
from kanboard_cli import client
class KanboardShell(app.App):
def __init__(self):
super(KanboardShell, self).__init__(
description='Kanboard Command Line Client',
version=app_version.VersionInfo('kanboard_cli').version_string(),
command_manager=commandmanager.CommandManager('kanboard.cli'),
deferred_help=True)
self.client = None
self.is_super_user = True
def build_option_parser(self, description, version, argparse_kwargs=None):
parser = super(KanboardShell, self).build_option_parser(
description, version, argparse_kwargs=argparse_kwargs)
parser.add_argument(
'--url',
metavar='<api url>',
help='Kanboard API URL',
)
parser.add_argument(
'--username',
metavar='<api username>',
help='API username',
)
parser.add_argument(
'--password',
metavar='<api password>',
help='API password/token',
)
parser.add_argument(
'--auth-header',
metavar='<authentication header>',
help='API authentication header',
)
return parser
def initialize_app(self, argv):
client_manager = client.ClientManager(self.options)
self.client = client_manager.get_client()
self.is_super_user = client_manager.is_super_user()
self.command_manager.add_command('app version', application.ShowVersion)
self.command_manager.add_command('app timezone', application.ShowTimezone)
self.command_manager.add_command('project show', project.ShowProject)
self.command_manager.add_command('project list', project.ListProjects)
self.command_manager.add_command('task create', task.CreateTask)
self.command_manager.add_command('task list', task.ListTasks)
def <|fim_middle|>(argv=sys.argv[1:]):
return KanboardShell().run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
<|fim▁end|> | main |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)<|fim▁hole|> 'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}<|fim▁end|> | labels = { |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_me<|fim_middle|>
ilField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | ssages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.Ema |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
<|fim_middle|>
ilField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.Ema |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_mes<|fim_middle|>
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | sages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
|
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, c<|fim_middle|>
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | ommit=True):
user = super(UserCreateForm, self).save(commit=False)
|
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"<|fim_middle|>
mail(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | ]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_e |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned<|fim_middle|>
cts.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | _data.get('email')
user = User.obje |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
<|fim_middle|>
ta.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_da |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not passw<|fim_middle|>
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | ord2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
|
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Me<|fim_middle|>
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | ta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
|
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = <|fim_middle|>
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
|
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fi<|fim_middle|>
<|fim▁end|> | elds = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
|
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messa<|fim_middle|>
<|fim▁end|> | ges,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
|
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["fu <|fim_middle|>
roup.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | ll_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return G |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site <|fim_middle|>
rs')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | -use |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clea <|fim_middle|>
ord2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | n_password2(self):
password1 = self.cleaned_data.get('password1')
passw |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationErr <|fim_middle|>
len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | or("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.Vali <|fim_middle|>
odelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | dationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.M |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField( <|fim_middle|>
}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> |
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100 |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.<|fim_middle|>l = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | emai |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self)<|fim_middle|>l = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | :
emai |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter<|fim_middle|>l).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | (email=emai |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('pa<|fim_middle|> if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
<|fim▁end|> | ssword2')
|
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.<|fim▁hole|>process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())<|fim▁end|> | """Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent |
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
<|fim_middle|>
eturn print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim▁end|> | Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
r |
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return print_banner(*<|fim_middle|>
<|fim▁end|> | *vars(parse()))
if __name__ == '__main__':
sys.exit(main())
|
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim_middle|>
<|fim▁end|> | |
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets <|fim_middle|>
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim▁end|> | your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
|
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
<|fim_middle|>
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim▁end|> | print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
|
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse. <|fim_middle|>
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim▁end|> | ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
|
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim_middle|>
<|fim▁end|> | |
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim_middle|>
<|fim▁end|> | |
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'ple<|fim_middle|>nt'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim▁end|> | ase be patie |
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return p<|fim_middle|>banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim▁end|> | rint_ |
<|file_name|>windows_env_start.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Prints the env_setup banner for cmd.exe.
This is done from Python as activating colors and printing ASCII art are not
easy to do in cmd.exe. Activated colors also don't persist in the parent
process.
"""
from __future__ import print_function
import argparse
import os
import sys
from .colors import Color, enable_colors # type: ignore
_PIGWEED_BANNER = u'''
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
'''
def print_banner(bootstrap, no_shell_file):
"""Print the Pigweed or project-specific banner"""
enable_colors()
print(Color.green('\n WELCOME TO...'))
print(Color.magenta(_PIGWEED_BANNER))
if bootstrap:
print(
Color.green('\n BOOTSTRAP! Bootstrap may take a few minutes; '
'please be patient'))
print(
Color.green(
' On Windows, this stage is extremely slow (~10 minutes).\n'))
else:
print(
Color.green(
'\n ACTIVATOR! This sets your console environment variables.\n'
))
if no_shell_file:
print(Color.bold_red('Error!\n'))
print(
Color.red(' Your Pigweed environment does not seem to be'
' configured.'))
print(Color.red(' Run bootstrap.bat to perform initial setup.'))
return 0
def parse():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--bootstrap', action='store_true')
parser.add_argument('--no-shell-file', action='store_true')
return parser.parse_args()
def main():
"""Script entry point."""
if os.name != 'nt':
return 1
return print_banner(**vars(parse()))
if __name__ == '__main__':
sys.exit(main())
<|fim_middle|><|fim▁end|> | |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""<|fim▁hole|> return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
<|fim_middle|>
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return [] |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
<|fim_middle|>
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | pass |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
<|fim_middle|>
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
<|fim_middle|>
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | return self.get_html(url, **kwargs) |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
<|fim_middle|>
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | return self.get_html(url, **kwargs) |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
<|fim_middle|>
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | return self.get_html(url, **kwargs) |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
<|fim_middle|>
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | """
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return [] |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
<|fim_middle|>
<|fim▁end|> | netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
<|fim_middle|>
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | raise HtmlError({'msg': 'external_request_fail', 'url': url}) |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
<|fim_middle|>
return None<|fim▁end|> | return site |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def <|fim_middle|>(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | __init__ |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def <|fim_middle|>(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | get_html |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def <|fim_middle|>(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | fetch_manga_seed_page |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def <|fim_middle|>(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | fetch_chapter_seed_page |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def <|fim_middle|>(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | fetch_page_image |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def <|fim_middle|>(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def get_site(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | search_by_author |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>"""
# Copyright (c) 05 2015 | surya
# 18/05/15 [email protected]
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# __init__.py.py
"""
import urlparse
from niimanga.libs.exceptions import HtmlError
from requests import request
class Site:
def __init__(self):
pass
def get_html(self, url, method='GET', **kwargs):
resp = request(method, url, **kwargs)
if resp.status_code != 200:
raise HtmlError({'msg': 'external_request_fail', 'url': url})
return resp.content
def fetch_manga_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_chapter_seed_page(self, url, **kwargs):
return self.get_html(url, **kwargs)
def fetch_page_image(self, url, **kwargs):
return self.get_html(url, **kwargs)
def search_by_author(self, author):
"""
Return list of chapter dicts whose keys are:
name
url
site
This should be specifically implemented in each Site subclass. If not,
this method will be used which returns an empty list.
"""
return []
from mangaeden import MangaEden
from batoto import Batoto
available_sites = [
# Kissmanga(),
# Vitaku(),
Batoto(),
# Mangafox(),
# Mangahere(),
# MangaHereMob(),
MangaEden()
]
# Factory function, return instance of suitable "site" class from url
def <|fim_middle|>(url):
netloc = urlparse.urlparse(url).netloc
for site in available_sites:
if netloc in site.netlocs:
return site
return None<|fim▁end|> | get_site |
<|file_name|>test_funcs.py<|end_file_name|><|fim▁begin|>import unittest
from libs.funcs import *
class TestFuncs(unittest.TestCase):
def test_buildPaths(self):
recPaths, repPaths, rouPaths, corePaths = buildPaths()
findTxt = lambda x, y: x.find(y) > -1
assert findTxt(recPaths["Task"][0], "base")
assert findTxt(recPaths["Department"][0], "StdPy")
assert findTxt(recPaths["Department"][1], "standard")<|fim▁hole|> assert findTxt(repPaths["ExpensesList"][1], "standard")
assert findTxt(rouPaths["GenNLT"][0], "StdPy")
assert findTxt(rouPaths["GenNLT"][1], "standard")
assert findTxt(corePaths["Field"][0], "embedded")
self.assertFalse([k for (k, v) in rouPaths.iteritems() if findTxt(v[0], "base")]) #no routines in base
def test_recordInheritance(self):
recf, recd = getRecordInheritance("Invoice")
assert all([f1 in recf for f1 in ("SalesMan", "InvoiceDate", "CustCode", "Currency", "ShiftDate", "OriginNr", "SerNr", "attachFlag")])
assert all([d in recd for d in ("CompoundItemCosts", "Payments", "Items", "Taxes", "Installs")])
recf, recd = getRecordInheritance("AccessGroup")
assert all([f2 in recf for f2 in ("PurchaseItemsAccessType", "InitialModule", "Closed", "internalId")])
assert all([d in recd for d in ("PurchaseItems", "Customs", "Modules")])
def test_recordsInfo(self):
recf, recd = getRecordsInfo("Department", RECORD)
assert recf["Department"]["AutoCashCancel"] == "integer" #From StdPy
assert recf["Department"]["DeptName"] == "string" #From standard
assert recf["Department"]["Closed"] == "Boolean" #From Master
assert recf["Department"]["internalId"] == "internalid" #From Record
assert recd["Department"]["OfficePayModes"] == "DepartmentOfficePayModeRow" #Recordname from detail
repf, repd = getRecordsInfo("Balance", REPORT)
assert repf["Balance"]["LabelType"] == "string" #StdPy
assert repf["Balance"]["ExplodeByLabel"] == "boolean" #Standard
assert repf["Balance"]["internalId"] == "internalid" #Record
assert not repd["Balance"] #Empty dict, no detail
rouf, roud = getRecordsInfo("GenNLT", ROUTINE)
assert rouf["GenNLT"]["ExcludeInvalid"] == "boolean"
assert rouf["GenNLT"]["Table"] == "string"
assert not roud["GenNLT"]
rouf, roud = getRecordsInfo("LoginDialog", RECORD)
assert rouf["LoginDialog"]["Password"] == "string" #embedded
assert not roud["LoginDialog"]
def test_classInfo(self):
attr, meth = getClassInfo("Invoice")
assert attr["DEBITNOTE"] == 2
assert attr["ATTACH_NOTE"] == 3
assert attr["rowNr"] == 0
assert attr["ParentInvoice"] == "SuperClass"
assert isinstance(attr["DocTypes"], list)
assert isinstance(attr["Origin"], dict)
assert all([m in meth for m in ("getCardReader", "logTransactionAction", "updateCredLimit",
"generateTaxes", "roundValue", "getOriginType", "bring", "getXML", "createField")])
assert meth["fieldIsEditable"][0] == "self"
assert meth["fieldIsEditable"][1] == "fieldname"
assert meth["fieldIsEditable"][2] == {"rowfieldname":'None'}
assert meth["fieldIsEditable"][3] == {"rownr":'None'}
attr, meth = getClassInfo("User")
assert attr["buffer"] == "RecordBuffer"
assert all([m in meth for m in ("store", "save", "load", "hasField")])
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestFuncs))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')<|fim▁end|> |
assert findTxt(repPaths["ListWindowReport"][0], "base")
assert findTxt(repPaths["ExpensesList"][0], "StdPy") |
<|file_name|>test_funcs.py<|end_file_name|><|fim▁begin|>import unittest
from libs.funcs import *
class TestFuncs(unittest.TestCase):
<|fim_middle|>
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestFuncs))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
<|fim▁end|> | def test_buildPaths(self):
recPaths, repPaths, rouPaths, corePaths = buildPaths()
findTxt = lambda x, y: x.find(y) > -1
assert findTxt(recPaths["Task"][0], "base")
assert findTxt(recPaths["Department"][0], "StdPy")
assert findTxt(recPaths["Department"][1], "standard")
assert findTxt(repPaths["ListWindowReport"][0], "base")
assert findTxt(repPaths["ExpensesList"][0], "StdPy")
assert findTxt(repPaths["ExpensesList"][1], "standard")
assert findTxt(rouPaths["GenNLT"][0], "StdPy")
assert findTxt(rouPaths["GenNLT"][1], "standard")
assert findTxt(corePaths["Field"][0], "embedded")
self.assertFalse([k for (k, v) in rouPaths.iteritems() if findTxt(v[0], "base")]) #no routines in base
def test_recordInheritance(self):
recf, recd = getRecordInheritance("Invoice")
assert all([f1 in recf for f1 in ("SalesMan", "InvoiceDate", "CustCode", "Currency", "ShiftDate", "OriginNr", "SerNr", "attachFlag")])
assert all([d in recd for d in ("CompoundItemCosts", "Payments", "Items", "Taxes", "Installs")])
recf, recd = getRecordInheritance("AccessGroup")
assert all([f2 in recf for f2 in ("PurchaseItemsAccessType", "InitialModule", "Closed", "internalId")])
assert all([d in recd for d in ("PurchaseItems", "Customs", "Modules")])
def test_recordsInfo(self):
recf, recd = getRecordsInfo("Department", RECORD)
assert recf["Department"]["AutoCashCancel"] == "integer" #From StdPy
assert recf["Department"]["DeptName"] == "string" #From standard
assert recf["Department"]["Closed"] == "Boolean" #From Master
assert recf["Department"]["internalId"] == "internalid" #From Record
assert recd["Department"]["OfficePayModes"] == "DepartmentOfficePayModeRow" #Recordname from detail
repf, repd = getRecordsInfo("Balance", REPORT)
assert repf["Balance"]["LabelType"] == "string" #StdPy
assert repf["Balance"]["ExplodeByLabel"] == "boolean" #Standard
assert repf["Balance"]["internalId"] == "internalid" #Record
assert not repd["Balance"] #Empty dict, no detail
rouf, roud = getRecordsInfo("GenNLT", ROUTINE)
assert rouf["GenNLT"]["ExcludeInvalid"] == "boolean"
assert rouf["GenNLT"]["Table"] == "string"
assert not roud["GenNLT"]
rouf, roud = getRecordsInfo("LoginDialog", RECORD)
assert rouf["LoginDialog"]["Password"] == "string" #embedded
assert not roud["LoginDialog"]
def test_classInfo(self):
attr, meth = getClassInfo("Invoice")
assert attr["DEBITNOTE"] == 2
assert attr["ATTACH_NOTE"] == 3
assert attr["rowNr"] == 0
assert attr["ParentInvoice"] == "SuperClass"
assert isinstance(attr["DocTypes"], list)
assert isinstance(attr["Origin"], dict)
assert all([m in meth for m in ("getCardReader", "logTransactionAction", "updateCredLimit",
"generateTaxes", "roundValue", "getOriginType", "bring", "getXML", "createField")])
assert meth["fieldIsEditable"][0] == "self"
assert meth["fieldIsEditable"][1] == "fieldname"
assert meth["fieldIsEditable"][2] == {"rowfieldname":'None'}
assert meth["fieldIsEditable"][3] == {"rownr":'None'}
attr, meth = getClassInfo("User")
assert attr["buffer"] == "RecordBuffer"
assert all([m in meth for m in ("store", "save", "load", "hasField")]) |
<|file_name|>test_funcs.py<|end_file_name|><|fim▁begin|>import unittest
from libs.funcs import *
class TestFuncs(unittest.TestCase):
def test_buildPaths(self):
<|fim_middle|>
def test_recordInheritance(self):
recf, recd = getRecordInheritance("Invoice")
assert all([f1 in recf for f1 in ("SalesMan", "InvoiceDate", "CustCode", "Currency", "ShiftDate", "OriginNr", "SerNr", "attachFlag")])
assert all([d in recd for d in ("CompoundItemCosts", "Payments", "Items", "Taxes", "Installs")])
recf, recd = getRecordInheritance("AccessGroup")
assert all([f2 in recf for f2 in ("PurchaseItemsAccessType", "InitialModule", "Closed", "internalId")])
assert all([d in recd for d in ("PurchaseItems", "Customs", "Modules")])
def test_recordsInfo(self):
recf, recd = getRecordsInfo("Department", RECORD)
assert recf["Department"]["AutoCashCancel"] == "integer" #From StdPy
assert recf["Department"]["DeptName"] == "string" #From standard
assert recf["Department"]["Closed"] == "Boolean" #From Master
assert recf["Department"]["internalId"] == "internalid" #From Record
assert recd["Department"]["OfficePayModes"] == "DepartmentOfficePayModeRow" #Recordname from detail
repf, repd = getRecordsInfo("Balance", REPORT)
assert repf["Balance"]["LabelType"] == "string" #StdPy
assert repf["Balance"]["ExplodeByLabel"] == "boolean" #Standard
assert repf["Balance"]["internalId"] == "internalid" #Record
assert not repd["Balance"] #Empty dict, no detail
rouf, roud = getRecordsInfo("GenNLT", ROUTINE)
assert rouf["GenNLT"]["ExcludeInvalid"] == "boolean"
assert rouf["GenNLT"]["Table"] == "string"
assert not roud["GenNLT"]
rouf, roud = getRecordsInfo("LoginDialog", RECORD)
assert rouf["LoginDialog"]["Password"] == "string" #embedded
assert not roud["LoginDialog"]
def test_classInfo(self):
attr, meth = getClassInfo("Invoice")
assert attr["DEBITNOTE"] == 2
assert attr["ATTACH_NOTE"] == 3
assert attr["rowNr"] == 0
assert attr["ParentInvoice"] == "SuperClass"
assert isinstance(attr["DocTypes"], list)
assert isinstance(attr["Origin"], dict)
assert all([m in meth for m in ("getCardReader", "logTransactionAction", "updateCredLimit",
"generateTaxes", "roundValue", "getOriginType", "bring", "getXML", "createField")])
assert meth["fieldIsEditable"][0] == "self"
assert meth["fieldIsEditable"][1] == "fieldname"
assert meth["fieldIsEditable"][2] == {"rowfieldname":'None'}
assert meth["fieldIsEditable"][3] == {"rownr":'None'}
attr, meth = getClassInfo("User")
assert attr["buffer"] == "RecordBuffer"
assert all([m in meth for m in ("store", "save", "load", "hasField")])
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestFuncs))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
<|fim▁end|> | recPaths, repPaths, rouPaths, corePaths = buildPaths()
findTxt = lambda x, y: x.find(y) > -1
assert findTxt(recPaths["Task"][0], "base")
assert findTxt(recPaths["Department"][0], "StdPy")
assert findTxt(recPaths["Department"][1], "standard")
assert findTxt(repPaths["ListWindowReport"][0], "base")
assert findTxt(repPaths["ExpensesList"][0], "StdPy")
assert findTxt(repPaths["ExpensesList"][1], "standard")
assert findTxt(rouPaths["GenNLT"][0], "StdPy")
assert findTxt(rouPaths["GenNLT"][1], "standard")
assert findTxt(corePaths["Field"][0], "embedded")
self.assertFalse([k for (k, v) in rouPaths.iteritems() if findTxt(v[0], "base")]) #no routines in base |
<|file_name|>test_funcs.py<|end_file_name|><|fim▁begin|>import unittest
from libs.funcs import *
class TestFuncs(unittest.TestCase):
def test_buildPaths(self):
recPaths, repPaths, rouPaths, corePaths = buildPaths()
findTxt = lambda x, y: x.find(y) > -1
assert findTxt(recPaths["Task"][0], "base")
assert findTxt(recPaths["Department"][0], "StdPy")
assert findTxt(recPaths["Department"][1], "standard")
assert findTxt(repPaths["ListWindowReport"][0], "base")
assert findTxt(repPaths["ExpensesList"][0], "StdPy")
assert findTxt(repPaths["ExpensesList"][1], "standard")
assert findTxt(rouPaths["GenNLT"][0], "StdPy")
assert findTxt(rouPaths["GenNLT"][1], "standard")
assert findTxt(corePaths["Field"][0], "embedded")
self.assertFalse([k for (k, v) in rouPaths.iteritems() if findTxt(v[0], "base")]) #no routines in base
def test_recordInheritance(self):
<|fim_middle|>
def test_recordsInfo(self):
recf, recd = getRecordsInfo("Department", RECORD)
assert recf["Department"]["AutoCashCancel"] == "integer" #From StdPy
assert recf["Department"]["DeptName"] == "string" #From standard
assert recf["Department"]["Closed"] == "Boolean" #From Master
assert recf["Department"]["internalId"] == "internalid" #From Record
assert recd["Department"]["OfficePayModes"] == "DepartmentOfficePayModeRow" #Recordname from detail
repf, repd = getRecordsInfo("Balance", REPORT)
assert repf["Balance"]["LabelType"] == "string" #StdPy
assert repf["Balance"]["ExplodeByLabel"] == "boolean" #Standard
assert repf["Balance"]["internalId"] == "internalid" #Record
assert not repd["Balance"] #Empty dict, no detail
rouf, roud = getRecordsInfo("GenNLT", ROUTINE)
assert rouf["GenNLT"]["ExcludeInvalid"] == "boolean"
assert rouf["GenNLT"]["Table"] == "string"
assert not roud["GenNLT"]
rouf, roud = getRecordsInfo("LoginDialog", RECORD)
assert rouf["LoginDialog"]["Password"] == "string" #embedded
assert not roud["LoginDialog"]
def test_classInfo(self):
attr, meth = getClassInfo("Invoice")
assert attr["DEBITNOTE"] == 2
assert attr["ATTACH_NOTE"] == 3
assert attr["rowNr"] == 0
assert attr["ParentInvoice"] == "SuperClass"
assert isinstance(attr["DocTypes"], list)
assert isinstance(attr["Origin"], dict)
assert all([m in meth for m in ("getCardReader", "logTransactionAction", "updateCredLimit",
"generateTaxes", "roundValue", "getOriginType", "bring", "getXML", "createField")])
assert meth["fieldIsEditable"][0] == "self"
assert meth["fieldIsEditable"][1] == "fieldname"
assert meth["fieldIsEditable"][2] == {"rowfieldname":'None'}
assert meth["fieldIsEditable"][3] == {"rownr":'None'}
attr, meth = getClassInfo("User")
assert attr["buffer"] == "RecordBuffer"
assert all([m in meth for m in ("store", "save", "load", "hasField")])
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestFuncs))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
<|fim▁end|> | recf, recd = getRecordInheritance("Invoice")
assert all([f1 in recf for f1 in ("SalesMan", "InvoiceDate", "CustCode", "Currency", "ShiftDate", "OriginNr", "SerNr", "attachFlag")])
assert all([d in recd for d in ("CompoundItemCosts", "Payments", "Items", "Taxes", "Installs")])
recf, recd = getRecordInheritance("AccessGroup")
assert all([f2 in recf for f2 in ("PurchaseItemsAccessType", "InitialModule", "Closed", "internalId")])
assert all([d in recd for d in ("PurchaseItems", "Customs", "Modules")]) |
<|file_name|>test_funcs.py<|end_file_name|><|fim▁begin|>import unittest
from libs.funcs import *
class TestFuncs(unittest.TestCase):
def test_buildPaths(self):
recPaths, repPaths, rouPaths, corePaths = buildPaths()
findTxt = lambda x, y: x.find(y) > -1
assert findTxt(recPaths["Task"][0], "base")
assert findTxt(recPaths["Department"][0], "StdPy")
assert findTxt(recPaths["Department"][1], "standard")
assert findTxt(repPaths["ListWindowReport"][0], "base")
assert findTxt(repPaths["ExpensesList"][0], "StdPy")
assert findTxt(repPaths["ExpensesList"][1], "standard")
assert findTxt(rouPaths["GenNLT"][0], "StdPy")
assert findTxt(rouPaths["GenNLT"][1], "standard")
assert findTxt(corePaths["Field"][0], "embedded")
self.assertFalse([k for (k, v) in rouPaths.iteritems() if findTxt(v[0], "base")]) #no routines in base
def test_recordInheritance(self):
recf, recd = getRecordInheritance("Invoice")
assert all([f1 in recf for f1 in ("SalesMan", "InvoiceDate", "CustCode", "Currency", "ShiftDate", "OriginNr", "SerNr", "attachFlag")])
assert all([d in recd for d in ("CompoundItemCosts", "Payments", "Items", "Taxes", "Installs")])
recf, recd = getRecordInheritance("AccessGroup")
assert all([f2 in recf for f2 in ("PurchaseItemsAccessType", "InitialModule", "Closed", "internalId")])
assert all([d in recd for d in ("PurchaseItems", "Customs", "Modules")])
def test_recordsInfo(self):
<|fim_middle|>
def test_classInfo(self):
attr, meth = getClassInfo("Invoice")
assert attr["DEBITNOTE"] == 2
assert attr["ATTACH_NOTE"] == 3
assert attr["rowNr"] == 0
assert attr["ParentInvoice"] == "SuperClass"
assert isinstance(attr["DocTypes"], list)
assert isinstance(attr["Origin"], dict)
assert all([m in meth for m in ("getCardReader", "logTransactionAction", "updateCredLimit",
"generateTaxes", "roundValue", "getOriginType", "bring", "getXML", "createField")])
assert meth["fieldIsEditable"][0] == "self"
assert meth["fieldIsEditable"][1] == "fieldname"
assert meth["fieldIsEditable"][2] == {"rowfieldname":'None'}
assert meth["fieldIsEditable"][3] == {"rownr":'None'}
attr, meth = getClassInfo("User")
assert attr["buffer"] == "RecordBuffer"
assert all([m in meth for m in ("store", "save", "load", "hasField")])
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestFuncs))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
<|fim▁end|> | recf, recd = getRecordsInfo("Department", RECORD)
assert recf["Department"]["AutoCashCancel"] == "integer" #From StdPy
assert recf["Department"]["DeptName"] == "string" #From standard
assert recf["Department"]["Closed"] == "Boolean" #From Master
assert recf["Department"]["internalId"] == "internalid" #From Record
assert recd["Department"]["OfficePayModes"] == "DepartmentOfficePayModeRow" #Recordname from detail
repf, repd = getRecordsInfo("Balance", REPORT)
assert repf["Balance"]["LabelType"] == "string" #StdPy
assert repf["Balance"]["ExplodeByLabel"] == "boolean" #Standard
assert repf["Balance"]["internalId"] == "internalid" #Record
assert not repd["Balance"] #Empty dict, no detail
rouf, roud = getRecordsInfo("GenNLT", ROUTINE)
assert rouf["GenNLT"]["ExcludeInvalid"] == "boolean"
assert rouf["GenNLT"]["Table"] == "string"
assert not roud["GenNLT"]
rouf, roud = getRecordsInfo("LoginDialog", RECORD)
assert rouf["LoginDialog"]["Password"] == "string" #embedded
assert not roud["LoginDialog"] |
<|file_name|>test_funcs.py<|end_file_name|><|fim▁begin|>import unittest
from libs.funcs import *
class TestFuncs(unittest.TestCase):
def test_buildPaths(self):
recPaths, repPaths, rouPaths, corePaths = buildPaths()
findTxt = lambda x, y: x.find(y) > -1
assert findTxt(recPaths["Task"][0], "base")
assert findTxt(recPaths["Department"][0], "StdPy")
assert findTxt(recPaths["Department"][1], "standard")
assert findTxt(repPaths["ListWindowReport"][0], "base")
assert findTxt(repPaths["ExpensesList"][0], "StdPy")
assert findTxt(repPaths["ExpensesList"][1], "standard")
assert findTxt(rouPaths["GenNLT"][0], "StdPy")
assert findTxt(rouPaths["GenNLT"][1], "standard")
assert findTxt(corePaths["Field"][0], "embedded")
self.assertFalse([k for (k, v) in rouPaths.iteritems() if findTxt(v[0], "base")]) #no routines in base
def test_recordInheritance(self):
recf, recd = getRecordInheritance("Invoice")
assert all([f1 in recf for f1 in ("SalesMan", "InvoiceDate", "CustCode", "Currency", "ShiftDate", "OriginNr", "SerNr", "attachFlag")])
assert all([d in recd for d in ("CompoundItemCosts", "Payments", "Items", "Taxes", "Installs")])
recf, recd = getRecordInheritance("AccessGroup")
assert all([f2 in recf for f2 in ("PurchaseItemsAccessType", "InitialModule", "Closed", "internalId")])
assert all([d in recd for d in ("PurchaseItems", "Customs", "Modules")])
def test_recordsInfo(self):
recf, recd = getRecordsInfo("Department", RECORD)
assert recf["Department"]["AutoCashCancel"] == "integer" #From StdPy
assert recf["Department"]["DeptName"] == "string" #From standard
assert recf["Department"]["Closed"] == "Boolean" #From Master
assert recf["Department"]["internalId"] == "internalid" #From Record
assert recd["Department"]["OfficePayModes"] == "DepartmentOfficePayModeRow" #Recordname from detail
repf, repd = getRecordsInfo("Balance", REPORT)
assert repf["Balance"]["LabelType"] == "string" #StdPy
assert repf["Balance"]["ExplodeByLabel"] == "boolean" #Standard
assert repf["Balance"]["internalId"] == "internalid" #Record
assert not repd["Balance"] #Empty dict, no detail
rouf, roud = getRecordsInfo("GenNLT", ROUTINE)
assert rouf["GenNLT"]["ExcludeInvalid"] == "boolean"
assert rouf["GenNLT"]["Table"] == "string"
assert not roud["GenNLT"]
rouf, roud = getRecordsInfo("LoginDialog", RECORD)
assert rouf["LoginDialog"]["Password"] == "string" #embedded
assert not roud["LoginDialog"]
def test_classInfo(self):
<|fim_middle|>
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestFuncs))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
<|fim▁end|> | attr, meth = getClassInfo("Invoice")
assert attr["DEBITNOTE"] == 2
assert attr["ATTACH_NOTE"] == 3
assert attr["rowNr"] == 0
assert attr["ParentInvoice"] == "SuperClass"
assert isinstance(attr["DocTypes"], list)
assert isinstance(attr["Origin"], dict)
assert all([m in meth for m in ("getCardReader", "logTransactionAction", "updateCredLimit",
"generateTaxes", "roundValue", "getOriginType", "bring", "getXML", "createField")])
assert meth["fieldIsEditable"][0] == "self"
assert meth["fieldIsEditable"][1] == "fieldname"
assert meth["fieldIsEditable"][2] == {"rowfieldname":'None'}
assert meth["fieldIsEditable"][3] == {"rownr":'None'}
attr, meth = getClassInfo("User")
assert attr["buffer"] == "RecordBuffer"
assert all([m in meth for m in ("store", "save", "load", "hasField")]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.