def Main(): '''Wrapper.''' v = CheckOpenShift() activate(browser=False, admin=False) application.debug = True WelcomeMessage(v['port']) http_server = HTTPServer(WSGIContainer(application)) http_server.listen(v['port'], v['ip']) IOLoop.instance().start()
def run(generate_pks, show_pks, host, port, uri): """Connect sandman to <URI> and start the API server/admin interface.""" app.config['SQLALCHEMY_DATABASE_URI'] = uri app.config['SANDMAN_GENERATE_PKS'] = generate_pks app.config['SANDMAN_SHOW_PKS'] = show_pks app.config['SERVER_HOST'] = host app.config['SERVER_PORT'] = port activate(name='sandmanctl') app.run(host=host, port=int(port), debug=True)
def run(generate_pks, show_pks, host, port, uri): """Connect sandman to <URI> and start the API server/admin interface.""" app.config['SQLALCHEMY_DATABASE_URI'] = uri app.config['SANDMAN_GENERATE_PKS'] = generate_pks app.config['SANDMAN_SHOW_PKS'] = show_pks app.config['SERVER_HOST'] = host app.config['SERVER_PORT'] = port activate(name='sandmanctl') app.run(host=host, port=int(port), debug=True)
def main(test_options=None): """Main entry point for script.""" options = test_options or docopt(__doc__) URI = options['URI'] app.config['SQLALCHEMY_DATABASE_URI'] = options['URI'] app.config['SANDMAN_GENERATE_PKS'] = options['--generate-pks'] or False app.config['SANDMAN_SHOW_PKS'] = options['--show-pks'] or False host = options.get('--host') or '0.0.0.0' port = options.get('--port') or 5000 app.config['SERVER_HOST'] = host app.config['SERVER_PORT'] = port activate(name='sandmanctl') app.run(host=host, port=int(port), debug=True)
def main(test_options=None): """Main entry point for script.""" options = test_options or docopt(__doc__) URI = options['URI'] app.config['SQLALCHEMY_DATABASE_URI'] = options['URI'] app.config['SANDMAN_GENERATE_PKS'] = options['--generate-pks'] or False app.config['SANDMAN_SHOW_PKS'] = options['--show-pks'] or False host = options.get('--host') or '0.0.0.0' port = options.get('--port') or 5000 app.config['SERVER_HOST'] = host app.config['SERVER_PORT'] = port activate(name='sandmanctl') app.run(host=host, port=int(port), debug=True)
def run(generate_pks, show_pks, host, port, debug, uri): """Start the admin UI for managing data <URI> is the database connection uri ex. sqlite:////path/to/file """ sandman.app.config['SQLALCHEMY_DATABASE_URI'] = uri sandman.app.config['SANDMAN_GENERATE_PKS'] = generate_pks sandman.app.config['SANDMAN_SHOW_PKS'] = show_pks sandman.app.config['SERVER_HOST'] = host sandman.app.config['SERVER_PORT'] = port model.activate(name='SeedboxManager Admin', browser=False) # set logging to dump output if in debug mode reqlogger = logging.getLogger('werkzeug') reqlogger.setLevel(logging.ERROR) if debug: reqlogger.setLevel(logging.DEBUG) sandman.app.run(host=host, port=int(port), debug=debug)
def main(test_options=None): """Main entry point for script.""" import pkg_resources version = None try: version = pkg_resources.get_distribution('sandman').version finally: del pkg_resources options = test_options or docopt(__doc__, version=version) URI = options['URI'] app.config['SQLALCHEMY_DATABASE_URI'] = options['URI'] app.config['SANDMAN_GENERATE_PKS'] = options['--generate-pks'] or False app.config['SANDMAN_SHOW_PKS'] = options['--show-pks'] or False host = options.get('--host') or '0.0.0.0' port = options.get('--port') or 5000 app.config['SERVER_HOST'] = host app.config['SERVER_PORT'] = port activate(name='sandmanctl') app.run(host=host, port=int(port), debug=True)
def do_server(self, args, arguments): """ Usage: server Options: -h --help -v verbose mode Description: Starts up a REST service and a WEB GUI so one can browse the data in an existing cloudmesh database. The location of the database is supposed to be in ~/.cloud,esh/cloudmesh.db """ # import warnings # with warnings.catch_warnings(): # warnings.filter("ignore") # ignore "SQLALCHEMY_TRACK_MODIFICATIONS") from sandman import app from sandman.model import activate filename = "sqlite:///{}".format( Config.path_expand(os.path.join("~", ".cloudmesh", "cloudmesh.db"))) print("database: {}".format(filename)) app.config['SQLALCHEMY_DATABASE_URI'] = filename app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False activate() app.run()
def do_server(self, args, arguments): """ Usage: server Options: -h --help -v verbose mode Description: Starts up a REST service and a WEB GUI so one can browse the data in an existing cloudmesh database. The location of the database is supposed to be in ~/.cloud,esh/cloudmesh.db """ # import warnings # with warnings.catch_warnings(): # warnings.filter("ignore") # ignore "SQLALCHEMY_TRACK_MODIFICATIONS") from sandman import app from sandman.model import activate filename = "sqlite:///{}".format(Config.path_expand( os.path.join("~", ".cloudmesh", "cloudmesh.db"))) print("database: {}".format(filename)) app.config['SQLALCHEMY_DATABASE_URI'] = filename app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False activate() app.run()
__tablename__ = 'Genre' def __str__(self): return self.Name class PlaylistTrack(Model): __tablename__ = 'PlaylistTrack' def __str__(self): return self.track.TrackId class MediaType(Model): __tablename__ = 'MediaType' def __str__(self): return self.Name class Genre(Model): __tablename__ = 'Genre' def __str__(self): return self.Name register( (Artist, Album, Playlist, Type, Track, MediaType, PlaylistTrack, Genre)) activate(admin=True, browser=False)
"""Test that foreign keys with non-trivial keys are properly ignored.""" from sandman.model import activate activate(admin=False, browser=False, reflect_all=True)
from sandman.model import register, activate, Model class JobSchedule(Model): __tablename__ = 'job_schedule' class DataSources(Model): __tablename__ = 'data_sources' register((JobSchedule, DataSources)) activate(admin=False)
Has a custom endpoint ("styles" rather than the default, "genres"). Only supports HTTP methods specified. Has a custom validator for the GET method. """ __tablename__ = 'Genre' __endpoint__ = 'styles' __methods__ = ('GET', 'DELETE') @staticmethod # pylint: disable=invalid-name def validate_GET(resource=None): """Return False if the request should not be processed. :param resource: resource related to current request :type resource: :class:`sandman.model.Model` or None """ if isinstance(resource, list): return True elif resource and resource.GenreId == 1: return False return True register((Artist, Album, Playlist, Track, MediaType)) register(Style) activate(browser=True)
"""Model mapped to the "Genre" table Has a custom endpoint ("styles" rather than the default, "genres"). Only supports HTTP methods specified. Has a custom validator for the GET method. """ __tablename__ = 'Genre' __endpoint__ = 'styles' __methods__ = ('GET', 'DELETE') @staticmethod def validate_GET(resource=None): """Return False if the request should not be processed. :param resource: resource related to current request :type resource: :class:`sandman.model.Model` or None """ if isinstance(resource, list): return True elif resource and resource.GenreId == 1: return False return True register((Artist, Album, Playlist, Track, MediaType)) register(Style) activate()
# __tablename__ = 'Artist' # # class Album(Model): # __tablename__ = 'Album' # # class Playlist(Model): # __tablename__ = 'Playlist' # class Actor(Model): # __tablename__ = 'actor' # # class Customer(Model): # __tablename__ = 'customer' # class Staff(Model): # __tablename__ = 'Staff' # class Store(Model): # __tablename__ = 'Store' # register((Actor, Customer)) activate(browser=True) app.run(debug=True) # class Api(): # def __init__(self): # app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///chinook' # register((Artist, Album, Playlist)) # app.run()
from sandman.model import register, activate, Model class JobSchedule(Model): __tablename__ = "job_schedule" class DataSources(Model): __tablename__ = "data_sources" register((JobSchedule, DataSources)) activate(admin=False)
APP_PATH = os.path.dirname(os.path.abspath(__file__)) DB_PATH = os.path.join(APP_PATH, 'db.sqlite') app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + DB_PATH from sandman.model import register, activate, Model class Poll(Model): __tablename__ = 'poll_poll' class Vote(Model): __tablename__ = 'poll_vote' class Item(Model): __tablename__ = 'poll_item' class User(Model): __tablename__ = 'auth_user' # # register can be called with an iterable or a single class register((Poll, Vote, Item, User)) activate(browser=False) app.run()
class Playlist(Model): __tablename__ = 'Playlist' def __str__(self): return self.Name class Type(Model): __tablename__ = 'Genre' def __str__(self): return self.Name class PlaylistTrack(Model): __tablename__ = 'PlaylistTrack' def __str__(self): return self.track.TrackId class MediaType(Model): __tablename__ = 'MediaType' def __str__(self): return self.Name class Genre(Model): __tablename__ = 'Genre' def __str__(self): return self.Name register((Artist, Album, Playlist, Type, Track, MediaType, PlaylistTrack, Genre)) activate(admin=True, browser=False)
return self.Title class Playlist(Model): __tablename__ = 'Playlist' def __str__(self): return self.Name class Type(Model): __tablename__ = 'Genre' def __str__(self): return self.Name class PlaylistTrack(Model): __tablename__ = 'PlaylistTrack' class MediaType(Model): __tablename__ = 'MediaType' def __str__(self): return self.Name register((Artist, Album, Playlist, Type, Track, MediaType, PlaylistTrack)) activate(admin=True)
class Artist(Model): __tablename__ = 'Artist' def __str__(self): return self.Name class Album(Model): __tablename__ = 'Album' def __str__(self): return self.Title class Playlist(Model): __tablename__ = 'Playlist' def __str__(self): return self.Name class Type(Model): __tablename__ = 'Genre' def __str__(self): return self.Name class PlaylistTrack(Model): __tablename__ = 'PlaylistTrack' class MediaType(Model): __tablename__ = 'MediaType' def __str__(self): return self.Name register((Artist, Album, Playlist, Type, Track, MediaType, PlaylistTrack)) activate(admin=True)