Exemplo n.º 1
0
def submit(hostname, submitter=None):
    """ Submit a new job to given host. """
    host = hostname + '-host'
    try:
        host_cfg = simcity.get_config().section(host)
    except:
        raise ValueError('%s not configured under %s section' %
                         (hostname, host))

    try:
        if submitter is None:
            if host_cfg['method'] == 'ssh':
                submitter = SSHSubmitter(
                    database=simcity.get_job_database(),
                    host=host_cfg['host'],
                    jobdir=host_cfg['path'],
                    prefix=hostname + '-')
            elif host_cfg['method'] == 'osmium':
                submitter = OsmiumSubmitter(
                    database=simcity.get_job_database(),
                    port=host_cfg['port'],
                    jobdir=host_cfg['path'],
                    prefix=hostname + '-')
            else:
                raise EnvironmentError('Connection method for %s unknown' %
                                       hostname)

        script = [host_cfg['script']]
    except KeyError:
        raise EnvironmentError(
            "Connection method for %s not well configured" % hostname)

    return submitter.submit(script)
Exemplo n.º 2
0
    def __init__(self, task_db=None, iterator=None, job_db=None, config=None):
        if task_db is None:
            task_db = simcity.get_task_database()
        super(ExecuteActor, self).__init__(task_db, iterator=iterator)

        if job_db is None:
            job_db = simcity.get_job_database()
        self.job_db = job_db

        if config is None:
            config = simcity.get_config()
        self.config = config.section("Execution")
Exemplo n.º 3
0
# 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.

''' Delete all documents from given view '''
from __future__ import print_function
import simcity
import argparse

if __name__ == '__main__':
    task_views = ['todo', 'done', 'locked']
    job_views = [
        'pending_jobs', 'active_jobs', 'finished_jobs', 'archived_jobs']
    parser = argparse.ArgumentParser(description="Remove all tasks in a view")
    parser.add_argument('view', choices=task_views + job_views,
                        help="View to remove documents from")
    parser.add_argument('-c', '--config', help="configuration file",
                        default=None)
    args = parser.parse_args()

    simcity.init(config=args.config)

    if args.view in task_views:
        db = simcity.get_task_database()
    else:
        db = simcity.get_job_database()

    is_deleted = db.delete_from_view(args.view)
    print("Deleted %d out of %d tasks from view %s" %
          (sum(is_deleted), len(is_deleted), args.view))