Trees | Indices | Help |
---|
|
1 import json 2 import time 3 import base64 4 from coprs import db 5 from coprs import models 6 from coprs import helpers 7 from coprs import exceptions 8 from flask import url_for12 13 @classmethod28315 """ 16 Return single action identified by `action_id` 17 """ 18 19 query = models.Action.query.filter(models.Action.id == action_id) 20 return query21 22 @classmethod24 query = models.Action.query 25 if action_type is not None: 26 query = query.filter(models.Action.action_type == 27 int(action_type)) 28 if result is not None: 29 query = query.filter(models.Action.result == 30 int(result)) 31 32 return query33 34 @classmethod36 """ 37 Return actions that aren't finished 38 """ 39 40 query = (models.Action.query 41 .filter(models.Action.result == 42 helpers.BackendResultEnum("waiting")) 43 .filter(models.Action.action_type != 44 helpers.ActionTypeEnum("legal-flag")) 45 .order_by(models.Action.created_on.asc())) 46 47 return query48 49 @classmethod51 """ 52 Return actions matching passed `ids` 53 """ 54 55 return models.Action.query.filter(models.Action.id.in_(ids))56 57 @classmethod59 """ 60 Update `action` object with `upd_dict` data 61 62 Updates result, message and ended_on parameters. 63 """ 64 65 for attr in ["result", "message", "ended_on"]: 66 value = upd_dict.get(attr, None) 67 if value: 68 setattr(action, attr, value) 69 70 db.session.add(action)71 72 @classmethod74 data_dict = { 75 "username": username, 76 "projectname": coprname, 77 "chroots": chroots 78 } 79 action = models.Action( 80 action_type=helpers.ActionTypeEnum("createrepo"), 81 object_type="None", 82 object_id=0, 83 old_value="", 84 data=json.dumps(data_dict), 85 created_on=int(time.time()), 86 ) 87 db.session.add(action)88 89 @classmethod91 """ Schedules build delete action 92 :type build: models.Build 93 """ 94 # don't delete skipped chroots 95 chroots_to_delete = [ 96 chroot.name for chroot in build.build_chroots 97 if chroot.state not in ["skipped"] 98 ] 99 if len(chroots_to_delete) == 0: 100 return 101 102 data_dict = { 103 "username": build.copr.owner_name, 104 "projectname": build.copr.name, 105 "chroots": chroots_to_delete 106 } 107 108 if build.is_older_results_naming_used: 109 if build.src_pkg_name is None or build.src_pkg_name == "": 110 return 111 data_dict["src_pkg_name"] = build.src_pkg_name 112 else: 113 data_dict["result_dir_name"] = build.result_dir_name 114 115 action = models.Action( 116 action_type=helpers.ActionTypeEnum("delete"), 117 object_type="build", 118 object_id=build.id, 119 old_value=build.copr.full_name, 120 data=json.dumps(data_dict), 121 created_on=int(time.time()) 122 ) 123 db.session.add(action)124 125 @classmethod127 """ Schedules build cancel action 128 :type build: models.Build 129 """ 130 for chroot in build.build_chroots: 131 if chroot.state != "running": 132 continue 133 134 data_dict = { 135 "task_id": chroot.task_id, 136 } 137 138 action = models.Action( 139 action_type=helpers.ActionTypeEnum("cancel_build"), 140 data=json.dumps(data_dict), 141 created_on=int(time.time()) 142 ) 143 db.session.add(action)144 145 @classmethod147 """ Schedules update comps.xml action 148 149 :type copr_chroot: models.CoprChroot 150 """ 151 152 if chroot.copr.is_a_group_project: 153 url_path = url_for('coprs_ns.group_chroot_view_comps', 154 group_name=chroot.copr.group.name, 155 coprname=chroot.copr.name, 156 chrootname=chroot.name) 157 else: 158 url_path = url_for('coprs_ns.chroot_view_comps', 159 username=chroot.copr.user.username, 160 coprname=chroot.copr.name, 161 chrootname=chroot.name) 162 163 data_dict = { 164 "ownername": chroot.copr.owner_name, 165 "projectname": chroot.copr.name, 166 "chroot": chroot.name, 167 "comps_present": chroot.comps_zlib is not None, 168 "url_path": url_path, 169 } 170 171 action = models.Action( 172 action_type=helpers.ActionTypeEnum("update_comps"), 173 object_type="copr_chroot", 174 data=json.dumps(data_dict), 175 created_on=int(time.time()) 176 ) 177 db.session.add(action)178 179 @classmethod181 """ Schedules update module_md.yaml action 182 183 :type copr_chroot: models.CoprChroot 184 """ 185 if chroot.copr.is_a_group_project: 186 url_path = url_for('coprs_ns.group_chroot_view_module_md', 187 group_name=chroot.copr.group.name, 188 coprname=chroot.copr.name, 189 chrootname=chroot.name) 190 else: 191 url_path = url_for('coprs_ns.chroot_view_module_md', 192 username=chroot.copr.user.username, 193 coprname=chroot.copr.name, 194 chrootname=chroot.name) 195 196 data_dict = { 197 "ownername": chroot.copr.owner_name, 198 "projectname": chroot.copr.name, 199 "chroot": chroot.name, 200 "module_md_present": chroot.module_md_zlib is not None, 201 "url_path": url_path, 202 } 203 204 action = models.Action( 205 action_type=helpers.ActionTypeEnum("update_module_md"), 206 object_type="copr_chroot", 207 data=json.dumps(data_dict), 208 created_on=int(time.time()) 209 ) 210 db.session.add(action)211 212 @classmethod214 """ 215 :type copr: models.Copr 216 """ 217 218 data_dict = { 219 "username": copr.owner_name, 220 "projectname": copr.name, 221 } 222 223 action = models.Action( 224 action_type=helpers.ActionTypeEnum("gen_gpg_key"), 225 object_type="copr", 226 data=json.dumps(data_dict), 227 created_on=int(time.time()), 228 ) 229 db.session.add(action)230 231 @classmethod233 action = models.Action( 234 action_type=helpers.ActionTypeEnum("rawhide_to_release"), 235 object_type="None", 236 data=json.dumps(data), 237 created_on=int(time.time()), 238 ) 239 db.session.add(action)240 241 @classmethod243 """ 244 :type src: models.Copr 245 :type dst: models.Copr 246 :type builds_map: dict where keys are forked builds IDs and values are IDs from the original builds. 247 """ 248 249 action = models.Action( 250 action_type=helpers.ActionTypeEnum("fork"), 251 object_type="copr", 252 old_value="{0}".format(src.full_name), 253 new_value="{0}".format(dst.full_name), 254 data=json.dumps({"user": dst.owner_name, "copr": dst.name, "builds_map": builds_map}), 255 created_on=int(time.time()), 256 ) 257 db.session.add(action)258 259 @classmethod261 """ 262 :type copr: models.Copr 263 :type modulemd: str content of module yaml file 264 """ 265 266 if not user.can_build_in(copr): 267 raise exceptions.InsufficientRightsException("You don't have permissions to build in this copr.") 268 269 data = { 270 "chroots": [c.name for c in copr.active_chroots], 271 } 272 273 action = models.Action( 274 action_type=helpers.ActionTypeEnum("build_module"), 275 object_type="module", 276 object_id=module.id, 277 old_value="", 278 new_value="", 279 data=json.dumps(data), 280 created_on=int(time.time()), 281 ) 282 db.session.add(action)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Dec 5 22:37:24 2016 | http://epydoc.sourceforge.net |