id
int64
0
843k
repository_name
stringlengths
7
55
file_path
stringlengths
9
332
class_name
stringlengths
3
290
human_written_code
stringlengths
12
4.36M
class_skeleton
stringlengths
19
2.2M
total_program_units
int64
1
9.57k
total_doc_str
int64
0
4.2k
AvgCountLine
float64
0
7.89k
AvgCountLineBlank
float64
0
300
AvgCountLineCode
float64
0
7.89k
AvgCountLineComment
float64
0
7.89k
AvgCyclomatic
float64
0
130
CommentToCodeRatio
float64
0
176
CountClassBase
float64
0
48
CountClassCoupled
float64
0
589
CountClassCoupledModified
float64
0
581
CountClassDerived
float64
0
5.37k
CountDeclInstanceMethod
float64
0
4.2k
CountDeclInstanceVariable
float64
0
299
CountDeclMethod
float64
0
4.2k
CountDeclMethodAll
float64
0
4.2k
CountLine
float64
1
115k
CountLineBlank
float64
0
9.01k
CountLineCode
float64
0
94.4k
CountLineCodeDecl
float64
0
46.1k
CountLineCodeExe
float64
0
91.3k
CountLineComment
float64
0
27k
CountStmt
float64
1
93.2k
CountStmtDecl
float64
0
46.1k
CountStmtExe
float64
0
90.2k
MaxCyclomatic
float64
0
759
MaxInheritanceTree
float64
0
16
MaxNesting
float64
0
34
SumCyclomatic
float64
0
6k
144,748
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0020_auto_20200521_0107.py
mmc.migrations.0020_auto_20200521_0107.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0019_auto_20200521_0025'), ] operations = [ migrations.AlterField( model_name='mmclog', name='hostname', field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='mmc.MMCHost'), ), migrations.AlterField( model_name='mmclog', name='script', field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='mmc.MMCScript'), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
18
2
16
3
15
0
3
3
2
0
1
0
0
144,749
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/models.py
mmc.models.MMCScript
class MMCScript(models.Model): created = models.DateField(auto_now=True) name = models.CharField(max_length=255, unique=True) ignore = models.BooleanField( default=False, help_text='All logs from this script will be ignored.') one_copy = models.BooleanField( default=DEFAULT_ONE_COPY, help_text='Only one copy of this script will be run.') save_on_error = models.BooleanField( default=False, help_text='This flag can be used only for ignored commands.') real_time = models.BooleanField( default=False, help_text='Real Time info about command (for long tasks).') interval_restriction = models.PositiveIntegerField( default=None, null=True, blank=True, help_text='Interval before script can be run again') calls = models.BigIntegerField('Number of calls', default=0) enable_queries = models.BooleanField( default=False, help_text='Profile queries numbers.') trigger_cpu = models.FloatField( null=True, blank=True, help_text='Set the threshold time for CPU') trigger_memory = models.FloatField( null=True, blank=True, help_text='Set the threshold MB for Memory') trigger_time = models.FloatField( null=True, blank=True, help_text='Set the threshold sec for execution time') trigger_queries = models.FloatField( null=True, blank=True, help_text='Set the threshold number of queries') enable_triggers = models.BooleanField( default=False, help_text='Enable triggers for receive email ' 'notification, if threshold of counters ' 'will be exceeded') temporarily_disabled = models.SmallIntegerField( default=0, choices=( (0, 'Enabled'), (1, 'Disabled / Raise error'), (2, 'Disabled / Silence mode'), ), help_text='Temporarily disable script execution') last_call = models.DateTimeField(auto_now=True) max_elapsed = models.FloatField(default=0.0) track_at_exit = models.BooleanField( default=True, help_text='Disable for uWSGI/Celery') def update_calls(self): MMCScript.objects.filter(pk=self.pk).update( calls=models.F('calls') + 1) def update_meta(self, max_elapsed=0): MMCScript.objects.filter(pk=self.pk).update( last_call=timezone.now()) if max_elapsed > self.max_elapsed: MMCScript.objects.filter(pk=self.pk).update( max_elapsed=max_elapsed) @classmethod def get_one_copy(cls, name): return cls.objects.get(name=name).one_copy @classmethod def get_track_at_exit(cls, name): return cls.objects.get(name=name).track_at_exit @classmethod def run_is_allowed(cls, name): script = cls.objects.get(name=name) interval_restriction = script.interval_restriction if not interval_restriction: return True logs = MMCLog.objects.filter(script=script).order_by('-id')[:1] if logs.exists(): if (timezone.now() - logs[0].start).seconds < interval_restriction: return False return True @classmethod def run_is_enabled(cls, name): script = cls.objects.get(name=name) return not script.temporarily_disabled @classmethod def exit_mode(cls, name): script = cls.objects.get(name=name) return script.temporarily_disabled class Meta: verbose_name = 'Script' verbose_name_plural = 'Scripts' def __str__(self): return self.name
class MMCScript(models.Model): def update_calls(self): pass def update_meta(self, max_elapsed=0): pass @classmethod def get_one_copy(cls, name): pass @classmethod def get_track_at_exit(cls, name): pass @classmethod def run_is_allowed(cls, name): pass @classmethod def run_is_enabled(cls, name): pass @classmethod def exit_mode(cls, name): pass class Meta: def __str__(self): pass
15
0
4
0
4
0
2
0
1
1
1
0
3
1
8
8
95
11
84
41
69
0
50
35
40
4
1
2
12
144,750
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/mixins.py
mmc.mixins.StdOut
class StdOut(object): def __init__(self): self.data = [] def write(self, message): self.data.append(message) try: sys.__stdout__.write(message) except Exception as err: sys.stderr.write("{0}".format(err)) def __getattr__(self, method): def call_method(*args, **kwargs): return getattr(sys.__stdout__, method)(*args, **kwargs) return call_method def get_stdout(self): return self.data
class StdOut(object): def __init__(self): pass def write(self, message): pass def __getattr__(self, method): pass def call_method(*args, **kwargs): pass def get_stdout(self): pass
6
0
4
0
3
0
1
0
1
1
0
0
4
1
4
4
20
5
15
8
9
0
15
7
9
2
1
1
6
144,751
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0015_auto__add_field_mmcscript_real_time.py
mmc.south_migrations.0015_auto__add_field_mmcscript_real_time.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.real_time' db.add_column('mmc_mmcscript', 'real_time', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.real_time' db.delete_column('mmc_mmcscript', 'real_time') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
67
6
59
5
56
2
7
5
4
1
1
0
2
144,752
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0016_auto__add_field_mmclog_queries.py
mmc.south_migrations.0016_auto__add_field_mmclog_queries.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCLog.queries' db.add_column('mmc_mmclog', 'queries', self.gf('django.db.models.fields.BigIntegerField')(default=0), keep_default=False) def backwards(self, orm): # Deleting field 'MMCLog.queries' db.delete_column('mmc_mmclog', 'queries') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
68
6
60
5
57
2
7
5
4
1
1
0
2
144,753
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0017_auto__add_field_mmcscript_enable_queries.py
mmc.south_migrations.0017_auto__add_field_mmcscript_enable_queries.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.enable_queries' db.add_column('mmc_mmcscript', 'enable_queries', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.enable_queries' db.delete_column('mmc_mmcscript', 'enable_queries') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_queries': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
69
6
61
5
58
2
7
5
4
1
1
0
2
144,754
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0018_auto__add_field_mmcscript_trigger_queries.py
mmc.south_migrations.0018_auto__add_field_mmcscript_trigger_queries.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.trigger_queries' db.add_column('mmc_mmcscript', 'trigger_queries', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.trigger_queries' db.delete_column('mmc_mmcscript', 'trigger_queries') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_queries': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_queries': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
70
6
62
5
59
2
7
5
4
1
1
0
2
144,755
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0019_auto__add_field_mmcscript_interval_restriction.py
mmc.south_migrations.0019_auto__add_field_mmcscript_interval_restriction.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.interval_restriction' db.add_column('mmc_mmcscript', 'interval_restriction', self.gf('django.db.models.fields.PositiveIntegerField')(default=None, null=True, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.interval_restriction' db.delete_column('mmc_mmcscript', 'interval_restriction') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_queries': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'interval_restriction': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_queries': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
71
6
63
5
60
2
7
5
4
1
1
0
2
144,756
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0020_auto__add_field_mmclog_is_fixed.py
mmc.south_migrations.0020_auto__add_field_mmclog_is_fixed.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCLog.is_fixed' db.add_column('mmc_mmclog', 'is_fixed', self.gf('django.db.models.fields.NullBooleanField')(default=None, null=True, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'MMCLog.is_fixed' db.delete_column('mmc_mmclog', 'is_fixed') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_fixed': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_queries': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'interval_restriction': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_queries': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
72
6
64
5
61
2
7
5
4
1
1
0
2
144,757
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0014_auto__add_field_mmcscript_calls.py
mmc.south_migrations.0014_auto__add_field_mmcscript_calls.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.calls' db.add_column('mmc_mmcscript', 'calls', self.gf('django.db.models.fields.BigIntegerField')(default=0), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.calls' db.delete_column('mmc_mmcscript', 'calls') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
66
6
58
5
55
2
7
5
4
1
1
0
2
144,758
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0021_auto__add_field_mmcscript_temporarily_disabled.py
mmc.south_migrations.0021_auto__add_field_mmcscript_temporarily_disabled.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.temporarily_disabled' db.add_column('mmc_mmcscript', 'temporarily_disabled', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.temporarily_disabled' db.delete_column('mmc_mmcscript', 'temporarily_disabled') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_fixed': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_queries': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'interval_restriction': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'temporarily_disabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_queries': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
73
6
65
5
62
2
7
5
4
1
1
0
2
144,759
LPgenerator/django-mmc
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LPgenerator_django-mmc/mmc/models.py
mmc.models.MMCHost.Meta
class Meta: verbose_name = 'Host' verbose_name_plural = 'Hosts'
class Meta: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
3
3
2
0
3
3
2
0
0
0
0
144,760
LPgenerator/django-mmc
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LPgenerator_django-mmc/mmc/models.py
mmc.models.MMCLog.Meta
class Meta: verbose_name = 'Log' verbose_name_plural = 'Logs'
class Meta: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
3
3
2
0
3
3
2
0
0
0
0
144,761
LPgenerator/django-mmc
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LPgenerator_django-mmc/mmc/models.py
mmc.models.MMCScript.Meta
class Meta: verbose_name = 'Script' verbose_name_plural = 'Scripts'
class Meta: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
3
3
2
0
3
3
2
0
0
0
0
144,762
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0022_auto__add_field_mmcscript_last_call__add_field_mmcscript_max_elapsed.py
mmc.south_migrations.0022_auto__add_field_mmcscript_last_call__add_field_mmcscript_max_elapsed.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.last_call' db.add_column('mmc_mmcscript', 'last_call', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=datetime.datetime(2016, 9, 23, 0, 0), blank=True), keep_default=False) # Adding field 'MMCScript.max_elapsed' db.add_column('mmc_mmcscript', 'max_elapsed', self.gf('django.db.models.fields.FloatField')(default=0.0), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.last_call' db.delete_column('mmc_mmcscript', 'last_call') # Deleting field 'MMCScript.max_elapsed' db.delete_column('mmc_mmcscript', 'max_elapsed') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['mmc.MMCScript']", 'symmetrical': 'False', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_fixed': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_queries': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'interval_restriction': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'last_call': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'max_elapsed': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'temporarily_disabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_queries': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
8
1
5
2
1
0.06
1
0
0
0
2
0
2
2
83
8
71
5
68
4
9
5
6
1
1
0
2
144,763
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/utils.py
mmc.utils.MonkeyProxy
class MonkeyProxy(object): def __init__(self, cls): monkey_bases = tuple( b._no_monkey for b in cls.__bases__ if hasattr(b, '_no_monkey')) for monkey_base in monkey_bases: for name, value in monkey_base.__dict__.iteritems(): setattr(self, name, value)
class MonkeyProxy(object): def __init__(self, cls): pass
2
0
6
0
6
0
3
0
1
1
0
0
1
0
1
1
7
0
7
5
5
0
6
5
4
3
1
2
3
144,764
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/test_cases.py
mmc.test_cases.MMCTestCase
class MMCTestCase(TestCase): def setUp(self): MMCEmail.objects.create(email='root@local.host') def __test_command(self, command, success): call_command(command) script = MMCScript.objects.filter(name=command) host = MMCHost.objects.all()[0] log = MMCLog.objects.filter(script=script, hostname=host) self.assertTrue(script.exists()) self.assertTrue(log.exists()) self.assertEquals(log.count(), 1) self.assertEquals(log[0].success, success) def __test_command_ignore(self, command): script = MMCScript.objects.create( name=command, ignore=True, save_on_error=False) call_command(command) log = MMCLog.objects.filter(script=script) self.assertFalse(log.exists()) def __check_email(self): self.assertEquals(len(mail.outbox), 1) self.assertEquals(mail.outbox[0].subject, SUBJECT) # store log def test_a_test_command(self): self.__test_command('test_command', True) def test_b_test_command_noargs(self): self.__test_command('test_command_noargs', True) def test_c_test_command_error(self): self.__test_command('test_command_error', False) self.__check_email() # ignore log def test_a_test_command_ignore(self): self.__test_command_ignore('test_command') def test_b_test_command_noargs_ignore(self): self.__test_command_ignore('test_command_noargs') def test_c_test_command_error_ignore(self): self.__test_command_ignore('test_command_error') # store into log for ignored commands def test_d_test_command_error_ignore_save(self): command = 'test_command_error' MMCScript.objects.create(name=command, ignore=True, save_on_error=True) self.__test_command(command, False) self.__check_email()
class MMCTestCase(TestCase): def setUp(self): pass def __test_command(self, command, success): pass def __test_command_ignore(self, command): pass def __check_email(self): pass def test_a_test_command(self): pass def test_b_test_command_noargs(self): pass def test_c_test_command_error(self): pass def test_a_test_command_ignore(self): pass def test_b_test_command_noargs_ignore(self): pass def test_c_test_command_error_ignore(self): pass def test_d_test_command_error_ignore_save(self): pass
12
0
4
0
3
0
1
0.08
1
4
4
0
11
0
11
11
57
15
39
18
27
3
38
18
26
1
1
0
11
144,765
LPgenerator/django-mmc
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LPgenerator_django-mmc/mmc/models.py
mmc.models.MMCEmail.Meta
class Meta: verbose_name = 'Email' verbose_name_plural = 'Emails'
class Meta: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
3
3
2
0
3
3
2
0
0
0
0
144,766
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0013_auto__add_field_mmclog_pid.py
mmc.south_migrations.0013_auto__add_field_mmclog_pid.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCLog.pid' db.add_column('mmc_mmclog', 'pid', self.gf('django.db.models.fields.IntegerField')(default=1), keep_default=False) def backwards(self, orm): # Deleting field 'MMCLog.pid' db.delete_column('mmc_mmclog', 'pid') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.04
1
0
0
0
2
0
2
2
65
6
57
5
54
2
7
5
4
1
1
0
2
144,767
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0012_auto__add_field_mmcscript_trigger_cpu__add_field_mmcscript_trigger_mem.py
mmc.south_migrations.0012_auto__add_field_mmcscript_trigger_cpu__add_field_mmcscript_trigger_mem.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.trigger_cpu' db.add_column('mmc_mmcscript', 'trigger_cpu', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False) # Adding field 'MMCScript.trigger_memory' db.add_column('mmc_mmcscript', 'trigger_memory', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False) # Adding field 'MMCScript.trigger_time' db.add_column('mmc_mmcscript', 'trigger_time', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False) # Adding field 'MMCScript.enable_triggers' db.add_column('mmc_mmcscript', 'enable_triggers', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.trigger_cpu' db.delete_column('mmc_mmcscript', 'trigger_cpu') # Deleting field 'MMCScript.trigger_memory' db.delete_column('mmc_mmcscript', 'trigger_memory') # Deleting field 'MMCScript.trigger_time' db.delete_column('mmc_mmcscript', 'trigger_time') # Deleting field 'MMCScript.enable_triggers' db.delete_column('mmc_mmcscript', 'enable_triggers') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
16
3
9
4
1
0.12
1
0
0
0
2
0
2
2
88
12
68
5
65
8
13
5
10
1
1
0
2
144,768
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0011_auto.py
mmc.south_migrations.0011_auto.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding M2M table for field ignore on 'MMCEmail' m2m_table_name = db.shorten_name('mmc_mmcemail_ignore') db.create_table(m2m_table_name, ( ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), ('mmcemail', models.ForeignKey(orm['mmc.mmcemail'], null=False)), ('mmcscript', models.ForeignKey(orm['mmc.mmcscript'], null=False)) )) db.create_unique(m2m_table_name, ['mmcemail_id', 'mmcscript_id']) def backwards(self, orm): # Removing M2M table for field ignore on 'MMCEmail' db.delete_table(db.shorten_name('mmc_mmcemail_ignore')) models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['mmc.MMCScript']", 'null': 'True', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
6
0
5
1
1
0.04
1
0
0
0
2
0
2
2
64
6
56
6
53
2
9
6
6
1
1
0
2
144,769
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/models.py
mmc.models.MMCEmail
class MMCEmail(models.Model): created = models.DateField(auto_now=True, editable=False) email = models.EmailField( help_text='Email will be used for send all exceptions from command.') ignore = models.ManyToManyField( MMCScript, blank=True, help_text='Helpful for different teams. ' 'Choose script which you want to ignore.') is_active = models.BooleanField( default=True, help_text='Email may be switched off for a little while.') def __str__(self): return self.email class Meta: verbose_name = 'Email' verbose_name_plural = 'Emails' @classmethod def send(cls, host_name, script_name, message, subject=SUBJECT): try: emails = list(cls.objects.values_list( 'email', flat=True ).filter(is_active=True).exclude(ignore__name=script_name)) if emails: subject = subject % dict(script=script_name, host=host_name) mail = import_module(MAIL_MODULE) mail.send_mail( subject, message, EMAIL_FROM, emails, fail_silently=True ) except Exception as err: print("[MMC] {0}".format(err))
class MMCEmail(models.Model): def __str__(self): pass class Meta: @classmethod def send(cls, host_name, script_name, message, subject=SUBJECT): pass
5
0
8
1
8
0
2
0
1
3
0
0
1
0
2
2
34
4
30
14
25
0
19
12
15
3
1
2
4
144,770
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/models.py
mmc.models.MMCHost
class MMCHost(models.Model): created = models.DateField(auto_now=True) name = models.CharField(max_length=255, unique=True) ignore = models.BooleanField( default=False, help_text='All logs from all scripts on this host will be ignored.') class Meta: verbose_name = 'Host' verbose_name_plural = 'Hosts' def __str__(self): return self.name
class MMCHost(models.Model): class Meta: def __str__(self): pass
3
0
2
0
2
0
1
0
1
0
0
0
1
0
1
1
13
2
11
8
8
0
9
8
6
1
1
0
1
144,771
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/models.py
mmc.models.MMCLog
class MMCLog(models.Model): created = models.DateField(auto_now=True) start = models.DateTimeField() end = models.DateTimeField(auto_now=True) elapsed = models.FloatField() hostname = models.ForeignKey(MMCHost, blank=True, null=True, on_delete=models.SET_NULL) script = models.ForeignKey(MMCScript, on_delete=models.PROTECT) success = models.NullBooleanField(default=None) error_message = models.TextField(blank=True, null=True) traceback = models.TextField(blank=True, null=True) sys_argv = models.CharField(max_length=255, blank=True, null=True) memory = models.FloatField(default=0.00) cpu_time = models.FloatField(default=0.00) was_notified = models.BooleanField(default=False) stdout_messages = models.TextField(blank=True, null=True) pid = models.IntegerField(default=1) queries = models.BigIntegerField(default=0) is_fixed = models.NullBooleanField(default=None) def __str__(self): return self.script.name class Meta: verbose_name = 'Log' verbose_name_plural = 'Logs' @classmethod def logging(cls, **kwargs): kwargs['script'] = MMCScript.objects.get_or_create( name=kwargs['script'])[0] kwargs['hostname'] = MMCHost.objects.get_or_create( name=kwargs['hostname'])[0] instance = kwargs.pop('instance', None) def do_save(): if instance is not None: return cls.objects.filter(pk=instance.pk).update(**kwargs) kwargs.get('script').update_calls() return cls.objects.create(**kwargs) if not kwargs['script'].ignore and not kwargs['hostname'].ignore: return do_save() if kwargs['success'] is False and kwargs['script'].save_on_error: return do_save() @classmethod def get_lock_time(cls, script_name): return round(int(cls.objects.values_list( 'elapsed', flat=True ).filter(script__name=script_name).order_by('-elapsed')[:1][0]) + 1)
class MMCLog(models.Model): def __str__(self): pass class Meta: @classmethod def logging(cls, **kwargs): pass def do_save(): pass @classmethod def get_lock_time(cls, script_name): pass
8
0
7
1
7
0
2
0
1
3
2
0
1
0
3
3
52
7
45
28
37
0
38
26
32
3
1
1
7
144,772
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0019_auto_20200521_0025.py
mmc.migrations.0019_auto_20200521_0025.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0018_auto_20160923_0847'), ] operations = [ migrations.AlterField( model_name='mmcemail', name='email', field=models.EmailField(help_text='Email will be used for send all exceptions from command.', max_length=254), ), migrations.AlterField( model_name='mmcemail', name='ignore', field=models.ManyToManyField(blank=True, help_text='Helpful for different teams. Choose script which you want to ignore.', to='mmc.MMCScript'), ), migrations.AlterField( model_name='mmcemail', name='is_active', field=models.BooleanField(default=True, help_text='Email may be switched off for a little while.'), ), migrations.AlterField( model_name='mmchost', name='ignore', field=models.BooleanField(default=False, help_text='All logs from all scripts on this host will be ignored.'), ), migrations.AlterField( model_name='mmcscript', name='calls', field=models.BigIntegerField(default=0, verbose_name='Number of calls'), ), migrations.AlterField( model_name='mmcscript', name='enable_queries', field=models.BooleanField(default=False, help_text='Profile queries numbers.'), ), migrations.AlterField( model_name='mmcscript', name='enable_triggers', field=models.BooleanField(default=False, help_text='Enable triggers for receive email notification, if threshold of counters will be exceeded'), ), migrations.AlterField( model_name='mmcscript', name='ignore', field=models.BooleanField(default=False, help_text='All logs from this script will be ignored.'), ), migrations.AlterField( model_name='mmcscript', name='interval_restriction', field=models.PositiveIntegerField(blank=True, default=None, help_text='Interval before script can be run again', null=True), ), migrations.AlterField( model_name='mmcscript', name='one_copy', field=models.BooleanField(default=False, help_text='Only one copy of this script will be run.'), ), migrations.AlterField( model_name='mmcscript', name='real_time', field=models.BooleanField(default=False, help_text='Real Time info about command (for long tasks).'), ), migrations.AlterField( model_name='mmcscript', name='save_on_error', field=models.BooleanField(default=False, help_text='This flag can be used only for ignored commands.'), ), migrations.AlterField( model_name='mmcscript', name='temporarily_disabled', field=models.SmallIntegerField(choices=[(0, 'Enabled'), (1, 'Disabled / Raise error'), (2, 'Disabled / Silence mode')], default=0, help_text='Temporarily disable script execution'), ), migrations.AlterField( model_name='mmcscript', name='track_at_exit', field=models.BooleanField(default=True, help_text='Disable for uWSGI/Celery'), ), migrations.AlterField( model_name='mmcscript', name='trigger_cpu', field=models.FloatField(blank=True, help_text='Set the threshold time for CPU', null=True), ), migrations.AlterField( model_name='mmcscript', name='trigger_memory', field=models.FloatField(blank=True, help_text='Set the threshold MB for Memory', null=True), ), migrations.AlterField( model_name='mmcscript', name='trigger_queries', field=models.FloatField(blank=True, help_text='Set the threshold number of queries', null=True), ), migrations.AlterField( model_name='mmcscript', name='trigger_time', field=models.FloatField(blank=True, help_text='Set the threshold sec for execution time', null=True), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
98
2
96
3
95
0
3
3
2
0
1
0
0
144,773
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/lock.py
mmc.lock.MemcacheLock
class MemcacheLock(RedisLock): def __init__(self, script): try: from memcache import Client except ImportError: from pylibmc import Client super(MemcacheLock, self).__init__(script) self._cli = Client(**defaults.MEMCACHED_CONFIG) self.random_wait()
class MemcacheLock(RedisLock): def __init__(self, script): pass
2
0
9
1
8
0
2
0
1
2
0
0
1
1
1
13
10
1
9
5
5
0
9
5
5
2
3
1
2
144,774
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0001_initial.py
mmc.south_migrations.0001_initial.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'MMCHost' db.create_table('mmc_mmchost', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('created', self.gf('django.db.models.fields.DateField')(auto_now=True, blank=True)), ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)), )) db.send_create_signal('mmc', ['MMCHost']) # Adding model 'MMCScript' db.create_table('mmc_mmcscript', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('created', self.gf('django.db.models.fields.DateField')(auto_now=True, blank=True)), ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)), )) db.send_create_signal('mmc', ['MMCScript']) # Adding model 'MMCLog' db.create_table('mmc_mmclog', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('created', self.gf('django.db.models.fields.DateField')(auto_now=True, blank=True)), ('start', self.gf('django.db.models.fields.DateTimeField')()), ('end', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), ('elapsed', self.gf('django.db.models.fields.FloatField')()), ('hostname', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['mmc.MMCHost'])), ('script', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['mmc.MMCScript'])), ('success', self.gf('django.db.models.fields.BooleanField')(default=False)), ('error_message', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), ('traceback', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), ('sys_argv', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), )) db.send_create_signal('mmc', ['MMCLog']) def backwards(self, orm): # Deleting model 'MMCHost' db.delete_table('mmc_mmchost') # Deleting model 'MMCScript' db.delete_table('mmc_mmcscript') # Deleting model 'MMCLog' db.delete_table('mmc_mmclog') models = { 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
22
3
16
3
1
0.1
1
0
0
0
2
0
2
2
79
12
61
5
58
6
14
5
11
1
1
0
2
144,775
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0002_auto__add_field_mmcscript_ignore__add_field_mmchost_ignore.py
mmc.south_migrations.0002_auto__add_field_mmcscript_ignore__add_field_mmchost_ignore.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.ignore' db.add_column('mmc_mmcscript', 'ignore', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) # Adding field 'MMCHost.ignore' db.add_column('mmc_mmchost', 'ignore', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.ignore' db.delete_column('mmc_mmcscript', 'ignore') # Deleting field 'MMCHost.ignore' db.delete_column('mmc_mmchost', 'ignore') models = { 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
7
2
3
2
1
0.11
1
0
0
0
2
0
2
2
52
10
38
5
35
4
9
5
6
1
1
0
2
144,776
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0003_auto__add_mmcemail.py
mmc.south_migrations.0003_auto__add_mmcemail.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'MMCEmail' db.create_table('mmc_mmcemail', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('created', self.gf('django.db.models.fields.DateField')(auto_now=True, blank=True)), ('email', self.gf('django.db.models.fields.EmailField')(max_length=75)), ('is_active', self.gf('django.db.models.fields.BooleanField')(default=True)), )) db.send_create_signal('mmc', ['MMCEmail']) def backwards(self, orm): # Deleting model 'MMCEmail' db.delete_table('mmc_mmcemail') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
6
0
5
1
1
0.04
1
0
0
0
2
0
2
2
57
6
49
5
46
2
8
5
5
1
1
0
2
144,777
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0004_auto__add_field_mmcscript_one_copy.py
mmc.south_migrations.0004_auto__add_field_mmcscript_one_copy.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.one_copy' db.add_column('mmc_mmcscript', 'one_copy', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.one_copy' db.delete_column('mmc_mmcscript', 'one_copy') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.04
1
0
0
0
2
0
2
2
54
6
46
5
43
2
7
5
4
1
1
0
2
144,778
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0005_auto__add_field_mmcscript_save_on_error.py
mmc.south_migrations.0005_auto__add_field_mmcscript_save_on_error.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.save_on_error' db.add_column(u'mmc_mmcscript', 'save_on_error', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.save_on_error' db.delete_column(u'mmc_mmcscript', 'save_on_error') models = { u'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, u'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, u'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mmc.MMCHost']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, u'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.04
1
0
0
0
2
0
2
2
55
6
47
5
44
2
7
5
4
1
1
0
2
144,779
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0006_auto__add_field_mmclog_memory.py
mmc.south_migrations.0006_auto__add_field_mmclog_memory.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCLog.memory' db.add_column(u'mmc_mmclog', 'memory', self.gf('django.db.models.fields.FloatField')(default=0.0), keep_default=False) def backwards(self, orm): # Deleting field 'MMCLog.memory' db.delete_column(u'mmc_mmclog', 'memory') models = { u'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, u'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, u'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mmc.MMCHost']"}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, u'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.04
1
0
0
0
2
0
2
2
56
6
48
5
45
2
7
5
4
1
1
0
2
144,780
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0007_auto__chg_field_mmclog_success.py
mmc.south_migrations.0007_auto__chg_field_mmclog_success.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Changing field 'MMCLog.success' db.alter_column('mmc_mmclog', 'success', self.gf('django.db.models.fields.NullBooleanField')(null=True)) def backwards(self, orm): # Changing field 'MMCLog.success' db.alter_column('mmc_mmclog', 'success', self.gf('django.db.models.fields.BooleanField')()) models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
1
2
1
1
0.04
1
0
0
0
2
0
2
2
54
6
46
5
43
2
7
5
4
1
1
0
2
144,781
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0008_auto__add_field_mmclog_cpu_time.py
mmc.south_migrations.0008_auto__add_field_mmclog_cpu_time.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCLog.cpu_time' db.add_column('mmc_mmclog', 'cpu_time', self.gf('django.db.models.fields.FloatField')(default=0.0), keep_default=False) def backwards(self, orm): # Deleting field 'MMCLog.cpu_time' db.delete_column('mmc_mmclog', 'cpu_time') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.04
1
0
0
0
2
0
2
2
57
6
49
5
46
2
7
5
4
1
1
0
2
144,782
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0009_auto__add_field_mmclog_was_notified.py
mmc.south_migrations.0009_auto__add_field_mmclog_was_notified.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCLog.was_notified' db.add_column('mmc_mmclog', 'was_notified', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Deleting field 'MMCLog.was_notified' db.delete_column('mmc_mmclog', 'was_notified') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.04
1
0
0
0
2
0
2
2
58
6
50
5
47
2
7
5
4
1
1
0
2
144,783
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0010_auto__add_field_mmclog_stdout_messages.py
mmc.south_migrations.0010_auto__add_field_mmclog_stdout_messages.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCLog.stdout_messages' db.add_column('mmc_mmclog', 'stdout_messages', self.gf('django.db.models.fields.TextField')(null=True, blank=True), keep_default=False) def backwards(self, orm): # Deleting field 'MMCLog.stdout_messages' db.delete_column('mmc_mmclog', 'stdout_messages') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.04
1
0
0
0
2
0
2
2
59
6
51
5
48
2
7
5
4
1
1
0
2
144,784
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/mixins.py
mmc.mixins.NoArgsCommand
class NoArgsCommand(BaseCommandMixin, NoArgsCommandOrigin): pass
class NoArgsCommand(BaseCommandMixin, NoArgsCommandOrigin): pass
1
0
0
0
0
0
0
0
2
0
0
0
0
0
0
28
2
0
2
1
1
0
2
1
1
0
2
0
0
144,785
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0018_auto_20160923_0847.py
mmc.migrations.0018_auto_20160923_0847.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0017_mmcscript_track_at_exit'), ] operations = [ migrations.AlterField( model_name='mmcscript', name='temporarily_disabled', field=models.SmallIntegerField(default=0, help_text=b'Temporarily disable script execution', choices=[(0, b'Enabled'), (1, b'Disabled / Raise error'), (2, b'Disabled / Silence mode')]), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
13
2
11
3
10
0
3
3
2
0
1
0
0
144,786
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/lock.py
mmc.lock.FileLock
class FileLock(AbstractLock): def unlock(self): if self.is_run(): os.unlink(self.get_lock_file()) def lock(self): open(self.get_lock_file(), 'w').close() def _cleanup_lock(self): if os.path.exists(self.get_lock_file()): created = datetime.datetime.fromtimestamp( os.path.getctime(self.get_lock_file())) seconds = (datetime.datetime.now() - created).seconds if seconds > self._lock_time: os.unlink(self.get_lock_file()) def is_run(self): self._cleanup_lock() return os.path.exists(self.get_lock_file())
class FileLock(AbstractLock): def unlock(self): pass def lock(self): pass def _cleanup_lock(self): pass def is_run(self): pass
5
0
4
0
4
0
2
0
1
1
0
0
4
0
4
12
19
3
16
7
11
0
15
7
10
3
2
2
7
144,787
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0016_auto_20160923_0751.py
mmc.migrations.0016_auto_20160923_0751.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0015_auto_20160706_1633'), ] operations = [ migrations.AddField( model_name='mmcscript', name='last_call', field=models.DateTimeField(default=datetime.datetime(2016, 9, 23, 12, 51, 43, 352472, tzinfo=utc), auto_now=True), preserve_default=False, ), migrations.AddField( model_name='mmcscript', name='max_elapsed', field=models.FloatField(default=0.0), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
19
2
17
3
16
0
3
3
2
0
1
0
0
144,788
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0001_squashed_dj2.py
mmc.migrations.0001_squashed_dj2.Migration
class Migration(migrations.Migration): replaces = [('mmc', '0001_initial'), ('mmc', '0002_mmclog_was_notified'), ('mmc', '0003_mmclog_stdout_messages'), ('mmc', '0004_mmcemail_ignore'), ('mmc', '0005_auto_20150315_0644'), ('mmc', '0006_auto_20150424_2114'), ('mmc', '0007_mmcscript_calls'), ('mmc', '0008_mmcscript_real_time'), ('mmc', '0009_auto_20150425_1540'), ('mmc', '0010_mmcscript_enable_queries'), ('mmc', '0011_auto_20150425_1710'), ('mmc', '0012_auto_20150717_0649'), ('mmc', '0013_mmclog_is_fixed'), ('mmc', '0014_mmcscript_temporarily_disabled'), ('mmc', '0015_auto_20160706_1633'), ('mmc', '0016_auto_20160923_0751'), ('mmc', '0017_mmcscript_track_at_exit'), ('mmc', '0018_auto_20160923_0847'), ('mmc', '0019_auto_20200521_0025'), ('mmc', '0020_auto_20200521_0107')] initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='MMCHost', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', models.DateField(auto_now=True)), ('name', models.CharField(max_length=255, unique=True)), ('ignore', models.BooleanField(default=False, help_text='All logs from all scripts on this host will be ignored.')), ], options={ 'verbose_name': 'Host', 'verbose_name_plural': 'Hosts', }, ), migrations.CreateModel( name='MMCScript', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', models.DateField(auto_now=True)), ('name', models.CharField(max_length=255, unique=True)), ('ignore', models.BooleanField(default=False, help_text='All logs from this script will be ignored.')), ('one_copy', models.BooleanField(default=False, help_text='Only one copy of this script will be run.')), ('save_on_error', models.BooleanField(default=False, help_text='This flag can be used only for ignored commands.')), ('enable_triggers', models.BooleanField(default=False, help_text='Enable triggers for receive email notification, if threshold of counters will be exceeded')), ('trigger_cpu', models.FloatField(blank=True, help_text='Set the threshold time for CPU', null=True)), ('trigger_memory', models.FloatField(blank=True, help_text='Set the threshold MB for Memory', null=True)), ('trigger_time', models.FloatField(blank=True, help_text='Set the threshold sec for execution time', null=True)), ('calls', models.BigIntegerField(default=0, verbose_name='Number of calls')), ('real_time', models.BooleanField(default=False, help_text='Real Time info about command (for long tasks).')), ('enable_queries', models.BooleanField(default=False, help_text='Profile queries numbers.')), ('trigger_queries', models.FloatField(blank=True, help_text='Set the threshold number of queries', null=True)), ('interval_restriction', models.PositiveIntegerField(blank=True, default=None, help_text='Interval before script can be run again', null=True)), ('temporarily_disabled', models.SmallIntegerField(choices=[(0, 'Enabled'), (1, 'Disabled / Raise error'), (2, 'Disabled / Silence mode')], default=0, help_text='Temporarily disable script execution')), ('last_call', models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 9, 23, 12, 51, 43, 352472, tzinfo=utc))), ('max_elapsed', models.FloatField(default=0.0)), ('track_at_exit', models.BooleanField(default=True, help_text='Disable for uWSGI/Celery')), ], options={ 'verbose_name': 'Script', 'verbose_name_plural': 'Scripts', }, ), migrations.CreateModel( name='MMCLog', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', models.DateField(auto_now=True)), ('start', models.DateTimeField()), ('end', models.DateTimeField(auto_now=True)), ('elapsed', models.FloatField()), ('success', models.NullBooleanField(default=None)), ('error_message', models.TextField(blank=True, null=True)), ('traceback', models.TextField(blank=True, null=True)), ('sys_argv', models.CharField(blank=True, max_length=255, null=True)), ('memory', models.FloatField(default=0.0)), ('cpu_time', models.FloatField(default=0.0)), ('hostname', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='mmc.MMCHost')), ('script', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='mmc.MMCScript')), ('was_notified', models.BooleanField(default=False)), ('stdout_messages', models.TextField(blank=True, null=True)), ('pid', models.IntegerField(default=1)), ('queries', models.BigIntegerField(default=0)), ('is_fixed', models.NullBooleanField(default=None)), ], options={ 'verbose_name': 'Log', 'verbose_name_plural': 'Logs', }, ), migrations.CreateModel( name='MMCEmail', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', models.DateField(auto_now=True)), ('email', models.EmailField(help_text='Email will be used for send all exceptions from command.', max_length=254)), ('is_active', models.BooleanField(default=True, help_text='Email may be switched off for a little while.')), ('ignore', models.ManyToManyField(blank=True, help_text='Helpful for different teams. Choose script which you want to ignore.', to='mmc.MMCScript')), ], options={ 'verbose_name': 'Email', 'verbose_name_plural': 'Emails', }, ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
93
4
89
5
88
0
5
5
4
0
1
0
0
144,789
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0001_initial.py
mmc.migrations.0001_initial.Migration
class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='MMCEmail', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('created', models.DateField(auto_now=True)), ('email', models.EmailField(help_text=b'Email will be used for send all exceptions from command.', max_length=75)), ('is_active', models.BooleanField(default=True, help_text=b'Email may be switched off for a little while.')), ], options={ 'verbose_name': 'Email', 'verbose_name_plural': 'Emails', }, bases=(models.Model,), ), migrations.CreateModel( name='MMCHost', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('created', models.DateField(auto_now=True)), ('name', models.CharField(unique=True, max_length=255)), ('ignore', models.BooleanField(default=False, help_text=b'All logs from all scripts on this host will be ignored.')), ], options={ 'verbose_name': 'Host', 'verbose_name_plural': 'Hosts', }, bases=(models.Model,), ), migrations.CreateModel( name='MMCLog', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('created', models.DateField(auto_now=True)), ('start', models.DateTimeField()), ('end', models.DateTimeField(auto_now=True)), ('elapsed', models.FloatField()), ('success', models.NullBooleanField(default=None)), ('error_message', models.TextField(null=True, blank=True)), ('traceback', models.TextField(null=True, blank=True)), ('sys_argv', models.CharField(max_length=255, null=True, blank=True)), ('memory', models.FloatField(default=0.0)), ('cpu_time', models.FloatField(default=0.0)), ('hostname', models.ForeignKey(to='mmc.MMCHost', on_delete=models.CASCADE)), ], options={ 'verbose_name': 'Log', 'verbose_name_plural': 'Logs', }, bases=(models.Model,), ), migrations.CreateModel( name='MMCScript', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('created', models.DateField(auto_now=True)), ('name', models.CharField(unique=True, max_length=255)), ('ignore', models.BooleanField(default=False, help_text=b'All logs from this script will be ignored.')), ('one_copy', models.BooleanField(default=False, help_text=b'Only one copy of this script will be run.')), ('save_on_error', models.BooleanField(default=False, help_text=b'This flag used only for ignored commands.')), ], options={ 'verbose_name': 'Script', 'verbose_name_plural': 'Scripts', }, bases=(models.Model,), ), migrations.AddField( model_name='mmclog', name='script', field=models.ForeignKey(to='mmc.MMCScript', on_delete=models.CASCADE), preserve_default=True, ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
79
2
77
3
76
0
3
3
2
0
1
0
0
144,790
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/management/commands/mmc_notify.py
mmc.management.commands.mmc_notify.Command
class Command(BaseCommand): @staticmethod def check_pid(pid, proc_name): try: import psutil if psutil.pid_exists(pid): process = psutil.Process(pid) if proc_name in process.cmdline(): return True except ImportError: pass def handle(self, **options): day_ago = (now() - datetime.timedelta(days=1)) two_day_ago = (day_ago - datetime.timedelta(days=1)) log_list = MMCLog.objects.filter( success__isnull=True, was_notified=False, created__range=[two_day_ago, day_ago]) for i, log in enumerate(log_list): if self.check_pid(log.pid, log.script.name): continue MMCEmail.send( log.hostname.name, log.script.name, 'Maybe script "%s" was killed by OS kernel.' % log.script.name) log.was_notified = True log.save() if i >= settings.NOTIFICATION_LIMIT: break
class Command(BaseCommand): @staticmethod def check_pid(pid, proc_name): pass def handle(self, **options): pass
4
0
15
2
13
0
4
0
1
6
2
0
1
0
2
2
32
5
27
10
22
0
22
9
18
4
1
3
8
144,791
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/management/commands/mmc_cleanup.py
mmc.management.commands.mmc_cleanup.Command
class Command(BaseCommand): option_list = BaseCommand.option_list + ( optparse.make_option( '-l', '--delta', action='store', dest='delta', default=0), optparse.make_option( '-d', '--date', action='store', dest='date', default=None), ) def __init__(self): super(Command, self).__init__() self.days_delta = 0 def _set_delta(self, options): self.days_delta = now() - datetime.timedelta( days=int(options.get('delta'))) if options.get('date'): dt = datetime.datetime.strptime(options.get('date'), '%Y-%m-%d') self.days_delta = (now() - dt) def _cleanup_model(self, model): model.objects.filter(created__lte=self.days_delta).delete() @staticmethod def _cleanup_ignored(): if CLEANUP_IGNORED is True: MMCLog.objects.filter( script__ignore=True, script__save_on_error=False).delete() def _cleanup(self): self._cleanup_model(MMCScript) self._cleanup_model(MMCHost) self._cleanup_model(MMCLog) self._cleanup_ignored() def handle(self, **options): self._set_delta(options) self._cleanup()
class Command(BaseCommand): def __init__(self): pass def _set_delta(self, options): pass def _cleanup_model(self, model): pass @staticmethod def _cleanup_ignored(): pass def _cleanup_model(self, model): pass def handle(self, **options): pass
8
0
4
0
4
0
1
0
1
7
3
0
5
1
6
6
38
7
31
11
23
0
23
10
16
2
1
1
8
144,792
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/lock.py
mmc.lock.RedisLock
class RedisLock(AbstractLock): def __init__(self, script): from redis import StrictRedis self._cli = StrictRedis(**defaults.REDIS_CONFIG) super(RedisLock, self).__init__(script) self.random_wait() def unlock(self): if self.is_run(): self._cli.delete(self.get_lock_file()) def lock(self): return self._cli.set(self.get_lock_file(), '1', self._lock_time) def is_run(self): return self._cli.get(self.get_lock_file())
class RedisLock(AbstractLock): def __init__(self, script): pass def unlock(self): pass def lock(self): pass def is_run(self): pass
5
0
3
0
3
0
1
0
1
1
0
1
4
1
4
12
17
4
13
7
7
0
13
7
7
2
2
1
5
144,793
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command_error_unicode.py
demo.apps.test.management.commands.test_command_error_unicode.Command
class Command(BaseCommand): def raise_exception(self): if mmc.PY2 is True: raise Exception(u'Привет, мир!') raise Exception('Привет, мир!') def handle(self, *args, **options): self.raise_exception()
class Command(BaseCommand): def raise_exception(self): pass def handle(self, *args, **options): pass
3
0
3
0
3
0
2
0
1
1
0
0
2
0
2
2
8
1
7
3
4
0
7
3
4
2
1
1
3
144,794
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command_killed.py
demo.apps.test.management.commands.test_command_killed.Command
class Command(BaseCommand): def handle(self, *args, **options): os._exit(-1)
class Command(BaseCommand): def handle(self, *args, **options): pass
2
0
2
0
2
0
1
0
1
0
0
0
1
0
1
1
3
0
3
2
1
0
3
2
1
1
1
0
1
144,795
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command_monitor.py
demo.apps.test.management.commands.test_command_monitor.Command
class Command(NoArgsCommand): def handle(self, *args, **options): if args: raise CommandError("Command doesn't accept any arguments") return self.handle_noargs(**options) def handle_noargs(self, *args, **options): time.sleep(4) print("OK.")
class Command(NoArgsCommand): def handle(self, *args, **options): pass def handle_noargs(self, *args, **options): pass
3
0
4
0
4
0
2
0
1
0
0
0
2
0
2
2
9
1
8
3
5
0
8
3
5
2
1
1
3
144,796
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0002_mmclog_was_notified.py
mmc.migrations.0002_mmclog_was_notified.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0001_initial'), ] operations = [ migrations.AddField( model_name='mmclog', name='was_notified', field=models.BooleanField(default=False), preserve_default=True, ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
14
2
12
3
11
0
3
3
2
0
1
0
0
144,797
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command_monitor_error.py
demo.apps.test.management.commands.test_command_monitor_error.Command
class Command(NoArgsCommand): def handle(self, *args, **options): if args: raise CommandError("Command doesn't accept any arguments") return self.handle_noargs(**options) def handle_noargs(self, *args, **options): time.sleep(4) raise Exception("Error ...")
class Command(NoArgsCommand): def handle(self, *args, **options): pass def handle_noargs(self, *args, **options): pass
3
0
4
0
4
0
2
0
1
1
0
0
2
0
2
2
9
1
8
3
5
0
8
3
5
2
1
1
3
144,798
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command_one.py
demo.apps.test.management.commands.test_command_one.Command
class Command(BaseCommand): def handle(self, *args, **options): sleep(300) print("OK")
class Command(BaseCommand): def handle(self, *args, **options): pass
2
0
3
0
3
0
1
0
1
0
0
0
1
0
1
1
4
0
4
2
2
0
4
2
2
1
1
0
1
144,799
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command_stdout.py
demo.apps.test.management.commands.test_command_stdout.Command
class Command(BaseCommand): def handle(self, *args, **options): print("Запросы:") pprint.pprint(connections['default'].queries, indent=4) raise Exception(u"Ошибочка")
class Command(BaseCommand): def handle(self, *args, **options): pass
2
0
4
0
4
0
1
0
1
1
0
0
1
0
1
1
5
0
5
2
3
0
5
2
3
1
1
0
1
144,800
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_subprocess.py
demo.apps.test.management.commands.test_subprocess.Command
class Command(BaseCommand): @staticmethod def ping(address): import os os.system('ping -c 4 %s' % address) def handle(self, *args, **options): use_subprocess = True self.run_at_subprocess(use_subprocess, self.ping, '8.8.8.8') print("Done")
class Command(BaseCommand): @staticmethod def ping(address): pass def handle(self, *args, **options): pass
4
0
4
1
4
0
1
0
1
0
0
0
1
0
2
2
11
2
9
6
4
0
8
5
4
1
1
0
2
144,801
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/admin.py
mmc.admin.MMCEmailAdmin
class MMCEmailAdmin(admin.ModelAdmin): list_display = ('email', 'is_active', 'created', 'id',) list_filter = ('created', 'is_active',) list_display_links = ('email',) filter_horizontal = ('ignore',) date_hierarchy = 'created' ordering = ('-id',) search_fields = ('email',)
class MMCEmailAdmin(admin.ModelAdmin): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
9
1
8
8
7
0
8
8
7
0
1
0
0
144,802
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0017_mmcscript_track_at_exit.py
mmc.migrations.0017_mmcscript_track_at_exit.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0016_auto_20160923_0751'), ] operations = [ migrations.AddField( model_name='mmcscript', name='track_at_exit', field=models.BooleanField(default=True, help_text=b'Disable for uWSGI/Celery'), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
13
2
11
3
10
0
3
3
2
0
1
0
0
144,803
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/admin.py
mmc.admin.MMCHostAdmin
class MMCHostAdmin(admin.ModelAdmin): list_display = ('name', 'ignore', 'created', 'id',) list_filter = ('created', 'ignore',) list_display_links = ('name',) readonly_fields = ('name',) date_hierarchy = 'created' ordering = ('-id',) search_fields = ('name',) def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False
class MMCHostAdmin(admin.ModelAdmin): def has_add_permission(self, request): pass def has_delete_permission(self, request, obj=None): pass
3
0
2
0
2
0
1
0
1
0
0
1
2
0
2
2
16
4
12
10
9
0
12
10
9
1
1
0
2
144,804
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/admin.py
mmc.admin.MMCLogAdmin
class MMCLogAdmin(admin.ModelAdmin): list_display = ( 'script', 'hostname', 'success', 'elapsed', 'memory', 'cpu_time', 'start', 'end', 'is_fixed') list_filter = ('success', 'is_fixed', 'script', 'hostname', 'created',) list_display_links = ('script',) list_editable = ['is_fixed'] readonly_fields = ( 'start', 'end', 'elapsed', 'hostname', 'script', 'queries', 'sys_argv', 'success', 'error_message', 'memory', 'cpu_time') fields = ( 'start', 'end', 'elapsed', 'hostname', 'script', 'memory', 'cpu_time', 'queries', 'sys_argv', 'success', 'error_message', 'traceback', 'stdout_messages') date_hierarchy = 'created' ordering = ('-id',) search_fields = ( 'error_message', 'traceback', 'hostname__name', 'script__name', ) def has_add_permission(self, request): return False def has_change_permission(self, request, obj=None): return request.method != 'POST' def has_delete_permission(self, request, obj=None): return False
class MMCLogAdmin(admin.ModelAdmin): def has_add_permission(self, request): pass def has_change_permission(self, request, obj=None): pass def has_delete_permission(self, request, obj=None): pass
4
0
2
0
2
0
1
0
1
0
0
0
3
0
3
3
34
6
28
13
24
0
16
13
12
1
1
0
3
144,805
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/admin.py
mmc.admin.MMCScriptAdmin
class MMCScriptAdmin(MMCHostAdmin): list_display = ( 'name', 'calls', 'max_elapsed_sec', 'ignore', 'one_copy', 'save_on_error', 'real_time', 'enable_queries', 'temporarily_disabled', 'enable_triggers', 'created', 'last_call', 'id') list_filter = ( 'temporarily_disabled', 'ignore', 'one_copy', 'save_on_error', 'real_time', 'enable_queries', 'enable_triggers', 'track_at_exit',) # list_editable = list_filter fieldsets = [ ('Basic', {'fields': [ 'temporarily_disabled', 'ignore', 'one_copy', 'save_on_error', 'real_time', 'enable_queries', 'track_at_exit', 'interval_restriction', ]}), ('Triggers', {'fields': [ 'enable_triggers', 'trigger_time', 'trigger_memory', 'trigger_cpu', 'trigger_queries', ]}), ] def max_elapsed_sec(self, cls): return '%0.2f sec' % cls.max_elapsed max_elapsed_sec.admin_order_field = 'max_elapsed' max_elapsed_sec.short_description = 'Max elapsed'
class MMCScriptAdmin(MMCHostAdmin): def max_elapsed_sec(self, cls): pass
2
0
2
0
2
0
1
0.04
1
0
0
0
1
0
1
3
26
1
24
5
22
1
8
5
6
1
2
0
1
144,806
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command_noargs.py
demo.apps.test.management.commands.test_command_noargs.Command
class Command(NoArgsCommand): def handle(self, *args, **options): if args: raise CommandError("Command doesn't accept any arguments") return self.handle_noargs(**options) def handle_noargs(self, *args, **options): print("OK")
class Command(NoArgsCommand): def handle(self, *args, **options): pass def handle_noargs(self, *args, **options): pass
3
0
3
0
3
0
2
0
1
0
0
0
2
0
2
2
8
1
7
3
4
0
7
3
4
2
1
1
3
144,807
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0003_mmclog_stdout_messages.py
mmc.migrations.0003_mmclog_stdout_messages.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0002_mmclog_was_notified'), ] operations = [ migrations.AddField( model_name='mmclog', name='stdout_messages', field=models.TextField(null=True, blank=True), preserve_default=True, ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
14
2
12
3
11
0
3
3
2
0
1
0
0
144,808
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0023_auto__add_field_mmcscript_track_at_exit.py
mmc.south_migrations.0023_auto__add_field_mmcscript_track_at_exit.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'MMCScript.track_at_exit' db.add_column('mmc_mmcscript', 'track_at_exit', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False) def backwards(self, orm): # Deleting field 'MMCScript.track_at_exit' db.delete_column('mmc_mmcscript', 'track_at_exit') models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['mmc.MMCScript']", 'symmetrical': 'False', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_fixed': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_queries': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'interval_restriction': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'last_call': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'max_elapsed': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'temporarily_disabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'track_at_exit': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_queries': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
0
3
1
1
0.03
1
0
0
0
2
0
2
2
76
6
68
5
65
2
7
5
4
1
1
0
2
144,809
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0005_auto_20150315_0644.py
mmc.migrations.0005_auto_20150315_0644.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0004_mmcemail_ignore'), ] operations = [ migrations.AddField( model_name='mmcscript', name='enable_triggers', field=models.BooleanField(default=False, help_text=b'Enable triggers for receive email notification, if threshold of counters will be exceeded'), preserve_default=True, ), migrations.AddField( model_name='mmcscript', name='trigger_cpu', field=models.FloatField(help_text=b'Set the threshold time for CPU', null=True, blank=True), preserve_default=True, ), migrations.AddField( model_name='mmcscript', name='trigger_memory', field=models.FloatField(help_text=b'Set the threshold MB for Memory', null=True, blank=True), preserve_default=True, ), migrations.AddField( model_name='mmcscript', name='trigger_time', field=models.FloatField(help_text=b'Set the threshold sec for execution', null=True, blank=True), preserve_default=True, ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
32
2
30
3
29
0
3
3
2
0
1
0
0
144,810
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command.py
demo.apps.test.management.commands.test_command.Command
class Command(BaseCommand): def handle(self, *args, **options): print("OK")
class Command(BaseCommand): def handle(self, *args, **options): pass
2
0
2
0
2
0
1
0
1
0
0
0
1
0
1
1
3
0
3
2
1
0
3
2
1
1
1
0
1
144,811
LPgenerator/django-mmc
LPgenerator_django-mmc/demo/apps/test/management/commands/test_command_error.py
demo.apps.test.management.commands.test_command_error.Command
class Command(BaseCommand): def raise_exception(self): raise Exception('Hello, World!') def handle(self, *args, **options): self.raise_exception()
class Command(BaseCommand): def raise_exception(self): pass def handle(self, *args, **options): pass
3
0
2
0
2
0
1
0
1
1
0
0
2
0
2
2
6
1
5
3
2
0
5
3
2
1
1
0
2
144,812
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0012_auto_20150717_0649.py
mmc.migrations.0012_auto_20150717_0649.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0011_auto_20150425_1710'), ] operations = [ migrations.AddField( model_name='mmcscript', name='interval_restriction', field=models.PositiveIntegerField(default=None, help_text=b'Interval before script can be run again', null=True, blank=True), ), migrations.AlterField( model_name='mmcscript', name='enable_queries', field=models.BooleanField(default=False, help_text=b'Profile queries numbers.'), ), migrations.AlterField( model_name='mmcscript', name='trigger_time', field=models.FloatField(help_text=b'Set the threshold sec for execution time', null=True, blank=True), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
23
2
21
3
20
0
3
3
2
0
1
0
0
144,813
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/south_migrations/0024_auto__chg_field_mmcscript_temporarily_disabled.py
mmc.south_migrations.0024_auto__chg_field_mmcscript_temporarily_disabled.Migration
class Migration(SchemaMigration): def forwards(self, orm): # Changing field 'MMCScript.temporarily_disabled' db.alter_column('mmc_mmcscript', 'temporarily_disabled', self.gf('django.db.models.fields.SmallIntegerField')()) def backwards(self, orm): # Changing field 'MMCScript.temporarily_disabled' db.alter_column('mmc_mmcscript', 'temporarily_disabled', self.gf('django.db.models.fields.BooleanField')()) models = { 'mmc.mmcemail': { 'Meta': {'object_name': 'MMCEmail'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['mmc.MMCScript']", 'symmetrical': 'False', 'blank': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}) }, 'mmc.mmchost': { 'Meta': {'object_name': 'MMCHost'}, 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'mmc.mmclog': { 'Meta': {'object_name': 'MMCLog'}, 'cpu_time': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'elapsed': ('django.db.models.fields.FloatField', [], {}), 'end': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'error_message': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'hostname': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCHost']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_fixed': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'memory': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'pid': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'queries': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'script': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['mmc.MMCScript']"}), 'start': ('django.db.models.fields.DateTimeField', [], {}), 'stdout_messages': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'success': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'sys_argv': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'traceback': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'was_notified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) }, 'mmc.mmcscript': { 'Meta': {'object_name': 'MMCScript'}, 'calls': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'created': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}), 'enable_queries': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'enable_triggers': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'interval_restriction': ('django.db.models.fields.PositiveIntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'last_call': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'max_elapsed': ('django.db.models.fields.FloatField', [], {'default': '0.0'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'one_copy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'real_time': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'save_on_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'temporarily_disabled': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}), 'track_at_exit': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'trigger_cpu': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_memory': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_queries': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'trigger_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}) } } complete_apps = ['mmc']
class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass
3
0
4
1
2
1
1
0.03
1
0
0
0
2
0
2
2
74
6
66
5
63
2
7
5
4
1
1
0
2
144,814
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0004_mmcemail_ignore.py
mmc.migrations.0004_mmcemail_ignore.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0003_mmclog_stdout_messages'), ] operations = [ migrations.AddField( model_name='mmcemail', name='ignore', field=models.ManyToManyField(help_text=b'Helpful for different teams. Choose script which you want to ignore.', to='mmc.MMCScript', null=True, blank=True), preserve_default=True, ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
14
2
12
3
11
0
3
3
2
0
1
0
0
144,815
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0013_mmclog_is_fixed.py
mmc.migrations.0013_mmclog_is_fixed.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0012_auto_20150717_0649'), ] operations = [ migrations.AddField( model_name='mmclog', name='is_fixed', field=models.NullBooleanField(default=None), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
13
2
11
3
10
0
3
3
2
0
1
0
0
144,816
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0011_auto_20150425_1710.py
mmc.migrations.0011_auto_20150425_1710.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0010_mmcscript_enable_queries'), ] operations = [ migrations.AddField( model_name='mmcscript', name='trigger_queries', field=models.FloatField( help_text=b'Set the threshold number of queries', null=True, blank=True), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
15
2
13
3
12
0
3
3
2
0
1
0
0
144,817
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0015_auto_20160706_1633.py
mmc.migrations.0015_auto_20160706_1633.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0014_mmcscript_temporarily_disabled'), ] operations = [ migrations.AlterField( model_name='mmcemail', name='ignore', field=models.ManyToManyField(help_text=b'Helpful for different teams. Choose script which you want to ignore.', to='mmc.MMCScript', blank=True), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
13
2
11
3
10
0
3
3
2
0
1
0
0
144,818
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0010_mmcscript_enable_queries.py
mmc.migrations.0010_mmcscript_enable_queries.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0009_auto_20150425_1540'), ] operations = [ migrations.AddField( model_name='mmcscript', name='enable_queries', field=models.BooleanField(default=False, help_text=b'Profile queries numbers'), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
13
2
11
3
10
0
3
3
2
0
1
0
0
144,819
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0006_auto_20150424_2114.py
mmc.migrations.0006_auto_20150424_2114.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0005_auto_20150315_0644'), ] operations = [ migrations.AddField( model_name='mmclog', name='pid', field=models.IntegerField(default=1), ), migrations.AlterField( model_name='mmcemail', name='email', field=models.EmailField(help_text=b'Email will be used for send all exceptions from command.', max_length=254), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
18
2
16
3
15
0
3
3
2
0
1
0
0
144,820
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0007_mmcscript_calls.py
mmc.migrations.0007_mmcscript_calls.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0006_auto_20150424_2114'), ] operations = [ migrations.AddField( model_name='mmcscript', name='calls', field=models.BigIntegerField(default=0, verbose_name=b'Number of calls'), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
13
2
11
3
10
0
3
3
2
0
1
0
0
144,821
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0008_mmcscript_real_time.py
mmc.migrations.0008_mmcscript_real_time.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0007_mmcscript_calls'), ] operations = [ migrations.AddField( model_name='mmcscript', name='real_time', field=models.BooleanField(default=False, help_text=b'Real Time info about command (for long tasks).'), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
13
2
11
3
10
0
3
3
2
0
1
0
0
144,822
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0009_auto_20150425_1540.py
mmc.migrations.0009_auto_20150425_1540.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0008_mmcscript_real_time'), ] operations = [ migrations.AddField( model_name='mmclog', name='queries', field=models.BigIntegerField(default=0), ), migrations.AlterField( model_name='mmcscript', name='save_on_error', field=models.BooleanField(default=False, help_text=b'This flag can be used only for ignored commands.'), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
18
2
16
3
15
0
3
3
2
0
1
0
0
144,823
LPgenerator/django-mmc
LPgenerator_django-mmc/mmc/migrations/0014_mmcscript_temporarily_disabled.py
mmc.migrations.0014_mmcscript_temporarily_disabled.Migration
class Migration(migrations.Migration): dependencies = [ ('mmc', '0013_mmclog_is_fixed'), ] operations = [ migrations.AddField( model_name='mmcscript', name='temporarily_disabled', field=models.BooleanField(default=False, help_text=b'Temporarily disable script execution'), ), ]
class Migration(migrations.Migration): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
13
2
11
3
10
0
3
3
2
0
1
0
0
144,824
LREN-CHUV/data-tracking
LREN-CHUV_data-tracking/data_tracking/connection.py
data_tracking.connection.Connection
class Connection: def __init__(self, db_url=None): if db_url is None: db_url = configuration.get('data-factory', 'DATA_CATALOG_SQL_ALCHEMY_CONN') self.Base = automap_base() self.engine = create_engine(db_url) self.Base.prepare(self.engine, reflect=True) self.ParticipantMapping = self.Base.classes.participant_mapping self.Participant = self.Base.classes.participant self.Visit = self.Base.classes.visit self.VisitMapping = self.Base.classes.visit_mapping self.DataFile = self.Base.classes.data_file self.Session = self.Base.classes.session self.SequenceType = self.Base.classes.sequence_type self.Sequence = self.Base.classes.sequence self.Repetition = self.Base.classes.repetition self.ProcessingStep = self.Base.classes.processing_step self.Provenance = self.Base.classes.provenance self.db_session = orm.Session(self.engine) def close(self): self.db_session.close() def get_dataset(self, step_id): provenance_id = self.db_session.query(self.ProcessingStep).filter_by(id=step_id).first().provenance_id return self.db_session.query(self.Provenance).filter_by(id=provenance_id).first().dataset def new_participant_id(self): try: return self.db_session.query( sql_func.max(self.ParticipantMapping.participant_id).label('max')).one().max + 1 except TypeError: return 0 def get_participant_id(self, participant_name, dataset): participant_name = str(participant_name) participant = self.db_session.query(self.ParticipantMapping).filter_by( dataset=dataset, name=participant_name).one_or_none() if not participant: participant = self.ParticipantMapping(dataset=dataset, name=participant_name, participant_id=self.new_participant_id()) self.db_session.merge(participant) self.db_session.commit() return self.db_session.query(self.ParticipantMapping).filter_by( dataset=dataset, name=participant_name).one_or_none().participant_id def new_visit_id(self): try: return self.db_session.query( sql_func.max(self.VisitMapping.visit_id).label('max')).one().max + 1 except TypeError: return 0 def get_visit_id(self, visit_name, dataset): visit_name = str(visit_name) visit = self.db_session.query(self.VisitMapping).filter_by( dataset=dataset, name=visit_name).one_or_none() if not visit: visit = self.VisitMapping(dataset=dataset, name=visit_name, visit_id=self.new_visit_id()) self.db_session.merge(visit) self.db_session.commit() return self.db_session.query(self.VisitMapping).filter_by( dataset=dataset, name=visit_name).one_or_none().visit_id def get_session_id(self, session_name, visit_id): session_name = str(session_name) session = self.db_session.query(self.Session).filter_by( name=session_name, visit_id=visit_id).one_or_none() if not session: session = self.Session(name=session_name, visit_id=visit_id) self.db_session.merge(session) self.db_session.commit() return self.db_session.query(self.Session).filter_by( name=session_name, visit_id=visit_id).one_or_none().id def get_sequence_id(self, sequence_name, session_id): sequence_name = str(sequence_name) sequence = self.db_session.query(self.Sequence).filter_by( name=sequence_name, session_id=session_id).one_or_none() if not sequence: sequence = self.Sequence(name=sequence_name, session_id=session_id) self.db_session.merge(sequence) self.db_session.commit() return self.db_session.query(self.Sequence).filter_by( name=sequence_name, session_id=session_id).one_or_none().id def get_repetition_id(self, repetition_name, sequence_id): repetition_name = str(repetition_name) repetition = self.db_session.query(self.Repetition).filter_by( name=repetition_name, sequence_id=sequence_id).one_or_none() if not repetition: repetition = self.Repetition(name=repetition_name, sequence_id=sequence_id) self.db_session.merge(repetition) self.db_session.commit() return self.db_session.query(self.Repetition).filter_by( name=repetition_name, sequence_id=sequence_id).one_or_none().id
class Connection: def __init__(self, db_url=None): pass def close(self): pass def get_dataset(self, step_id): pass def new_participant_id(self): pass def get_participant_id(self, participant_name, dataset): pass def new_visit_id(self): pass def get_visit_id(self, visit_name, dataset): pass def get_session_id(self, session_name, visit_id): pass def get_sequence_id(self, sequence_name, session_id): pass def get_repetition_id(self, repetition_name, sequence_id): pass
11
0
9
0
9
0
2
0
0
2
0
0
10
14
10
10
100
13
87
31
76
0
74
31
63
2
0
1
18
144,825
LREN-CHUV/data-tracking
LREN-CHUV_data-tracking/tests/unit_test.py
tests.unit_test.TestFilesRecording
class TestFilesRecording: def __init__(self): self.db_conn = None @classmethod def setup_class(cls): pass @classmethod def teardown_class(cls): pass def setup(self): self.db_conn = connection.Connection(DB_URL) def teardown(self): self.db_conn.close() def test_01_visit(self): """ This is a basic use case. First, we want to visit a DICOM data-set after the 'ACQUISITION' process. Then, we want to visit a NIFTI data-set generated from the previous DICOM files after the 'DICOM2NIFTI' process. """ # Create a simple provenance provenance_id = files_recording.create_provenance('TEST_DATA', db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.Provenance).filter_by( dataset='TEST_DATA', matlab_version=None).count(), 1) # Visit DICOM files acquisition_step_id = files_recording.visit('./data/dcm/', provenance_id, 'ACQUISITION', config=['sid_by_patient', 'pid_in_vid'], db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( processing_step_id=acquisition_step_id).count(), 4) # Create a provenance with some fake Matlab and SPM version numbers provenance_id2 = files_recording.create_provenance('TEST_DATA', software_versions={ 'matlab_version': '2016R', 'spm_version': 'v12'}, db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.Provenance).filter_by( dataset='TEST_DATA', matlab_version='2016R').count(), 1) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='DICOM', processing_step_id=acquisition_step_id).count(), 3) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='NIFTI', processing_step_id=acquisition_step_id).count(), 0) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='other', processing_step_id=acquisition_step_id).count(), 1) # Visit NIFTI files acquisition_step_id2 = files_recording.visit('./data/nii/', provenance_id2, 'DICOM2NIFTI', acquisition_step_id, config=['sid_by_patient', 'pid_in_vid'], db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( processing_step_id=acquisition_step_id2).count(), 3) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='DICOM', processing_step_id=acquisition_step_id2).count(), 0) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='NIFTI', processing_step_id=acquisition_step_id2).count(), 3) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='other', processing_step_id=acquisition_step_id2).count(), 0) def test_02_visit_again(self): """ Here, run again the test_01_visit so we can check that there are no duplicates in the DB. """ # Create a simple provenance provenance_id = files_recording.create_provenance('TEST_DATA', db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.Provenance).filter_by( dataset='TEST_DATA', matlab_version=None).count(), 1) # Visit DICOM files acquisition_step_id = files_recording.visit('./data/dcm/', provenance_id, 'ACQUISITION', config=['sid_by_patient', 'pid_in_vid'], db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( processing_step_id=acquisition_step_id).count(), 4) # Create a provenance with some fake Matlab and SPM version numbers provenance_id2 = files_recording.create_provenance('TEST_DATA', software_versions={ 'matlab_version': '2016R', 'spm_version': 'v12'}, db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.Provenance).filter_by( dataset='TEST_DATA', matlab_version='2016R').count(), 1) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='DICOM', processing_step_id=acquisition_step_id).count(), 3) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='NIFTI', processing_step_id=acquisition_step_id).count(), 0) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='other', processing_step_id=acquisition_step_id).count(), 1) # Visit NIFTI files acquisition_step_id2 = files_recording.visit('./data/nii/', provenance_id2, 'DICOM2NIFTI', acquisition_step_id, config=['sid_by_patient', 'pid_in_vid'], db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( processing_step_id=acquisition_step_id2).count(), 3) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='DICOM', processing_step_id=acquisition_step_id2).count(), 0) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='NIFTI', processing_step_id=acquisition_step_id2).count(), 3) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='other', processing_step_id=acquisition_step_id2).count(), 0) def test_03_visit_special(self): """ This test tries to visit special files. These can be copies from already loaded files, DICOM with missing fields, etc. """ # Create a simple provenance provenance_id = files_recording.create_provenance('TEST_DATA2', db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.Provenance).filter_by(dataset='TEST_DATA2').count(), 1) # Visit various files acquisition_step_id = files_recording.visit('./data/any/', provenance_id, 'SPECIAL', 1, db_url=DB_URL) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( processing_step_id=acquisition_step_id).count(), 1) # A few more things to check assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='DICOM', processing_step_id=acquisition_step_id).count(), 1) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( type='NIFTI', processing_step_id=acquisition_step_id).count(), 0) assert_equal(self.db_conn.db_session.query(self.db_conn.DataFile).filter_by( is_copy=True, processing_step_id=acquisition_step_id).count(), 1)
class TestFilesRecording: def __init__(self): pass @classmethod def setup_class(cls): pass @classmethod def teardown_class(cls): pass def setup_class(cls): pass def teardown_class(cls): pass def test_01_visit(self): ''' This is a basic use case. First, we want to visit a DICOM data-set after the 'ACQUISITION' process. Then, we want to visit a NIFTI data-set generated from the previous DICOM files after the 'DICOM2NIFTI' process. ''' pass def test_02_visit_again(self): ''' Here, run again the test_01_visit so we can check that there are no duplicates in the DB. ''' pass def test_03_visit_special(self): ''' This test tries to visit special files. These can be copies from already loaded files, DICOM with missing fields, etc. ''' pass
11
3
15
2
10
3
1
0.27
0
1
1
0
6
1
8
8
130
22
85
22
74
23
49
20
40
1
0
0
8
144,826
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestGet
class TestGet(unittest.TestCase): schema_name = "lists" query_name = "TheTestList" def setUp(self): class MockGet(MockLabKey): api = "getDomain.api" default_action = domain_controller default_success_body = {} self.service = MockGet() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "headers": None, "params": {"schemaName": self.schema_name, "queryName": self.query_name}, "timeout": 300, "allow_redirects": False, } self.args = [ mock_server_context(self.service), self.schema_name, self.query_name, ] def test_success(self): test = self success_test_get( test, self.service.get_successful_response(), get, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test_get( test, RequestAuthorizationError, self.service.get_unauthorized_response(), get, *self.args, **self.expected_kwargs )
class TestGet(unittest.TestCase): def setUp(self): pass class MockGet(MockLabKey): def test_success(self): pass def test_unauthorized(self): pass
5
0
14
1
13
0
1
0
1
2
2
0
3
3
3
75
47
6
41
15
36
0
17
15
12
1
2
0
3
144,827
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestInferFields
class TestInferFields(unittest.TestCase): def setUp(self): class MockInferFields(MockLabKey): api = "inferDomain.api" default_action = domain_controller default_success_body = {} self.service = MockInferFields() self.fd, self.path = tempfile.mkstemp() with os.fdopen(self.fd, "w") as tmp: tmp.write("Name\tAge\nNick\t32\nBrian\t27\n") self.file = tmp self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": None, "files": {"inferfile": self.file}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.file] def tearDown(self): os.remove(self.path) def test_success(self): test = self success_test( test, self.service.get_successful_response(), infer_fields, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), infer_fields, *self.args, **self.expected_kwargs )
class TestInferFields(unittest.TestCase): def setUp(self): pass class MockInferFields(MockLabKey): def tearDown(self): pass def test_success(self): pass def test_unauthorized(self): pass
6
0
11
1
10
0
1
0
1
2
2
0
4
6
4
76
49
7
42
17
36
0
21
16
15
1
2
1
4
144,828
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestSave
class TestSave(unittest.TestCase): domain = Domain( **{ "container": "TestContainer", "description": "A Test Domain", "domain_id": 9823, } ) schema_name = "lists" query_name = "TheTestList" def setUp(self): class MockSave(MockLabKey): api = "saveDomain.api" default_action = domain_controller default_success_body = {} self.service = MockSave() payload = { "domainDesign": self.domain.to_json(), "queryName": self.query_name, "schemaName": self.schema_name, } self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": json.dumps(payload, sort_keys=True), "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [ mock_server_context(self.service), self.schema_name, self.query_name, self.domain, ] def test_success(self): test = self success_test( test, self.service.get_successful_response(), save, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), save, *self.args, **self.expected_kwargs )
class TestSave(unittest.TestCase): def setUp(self): pass class MockSave(MockLabKey): def test_success(self): pass def test_unauthorized(self): pass
5
0
16
1
15
0
1
0
1
2
2
0
3
3
3
75
61
7
54
17
49
0
19
17
14
1
2
0
3
144,829
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_experiment_api.py
unit.test_experiment_api.MockLoadBatch
class MockLoadBatch(MockLabKey): api = "getAssayBatch.api" default_action = "assay" default_success_body = { "assayId": 2809, "batch": { "lsid": "urn:lsid:labkey.com:Experiment.Folder-1721:465ad7db-58d8-1033-a587-7eb0c02c2efe", "createdBy": "", "created": "2015/10/19 18:21:57", "name": "python batch", "modified": "2015/10/19 18:21:57", "modifiedBy": "", "comment": None, "id": 120, "runs": [ { "dataOutputs": [], "dataRows": [ { "Treatment Group": None, "Start Date": None, "Height _inches_": None, "Comments": None, "Status of Infection": None, "Country": None, "Gender": None, "Group Assignment": None, "Participant ID": None, "Date": None, }, { "Treatment Group": None, "Start Date": None, "Height _inches_": None, "Comments": None, "Status of Infection": None, "Country": None, "Gender": None, "Group Assignment": None, "Participant ID": None, "Date": None, }, { "Treatment Group": None, "Start Date": None, "Height _inches_": None, "Comments": None, "Status of Infection": None, "Country": None, "Gender": None, "Group Assignment": None, "Participant ID": None, "Date": None, }, ], "dataInputs": [], "created": "2015/10/19 18:21:57", "materialInputs": [ { "lsid": "urn:lsid:labkey.com:AssayRunMaterial.Folder-1721:Unknown", "role": "Sample", "created": "2015/10/19 18:21:57", "name": "Unknown", "modified": "2015/10/19 18:21:57", "id": 7641, } ], "lsid": "urn:lsid:labkey.com:GeneralAssayRun.Folder-1721:465ad7dd-58d8-1033-a587-7eb0c02c2efe", "materialOutputs": [], "createdBy": "", "name": "python upload", "modified": "2015/10/19 18:21:57", "modifiedBy": "", "comment": None, "id": 1526, "properties": {}, } ], "properties": {"ParticipantVisitResolver": None, "TargetStudy": None}, }, }
class MockLoadBatch(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
81
0
81
4
80
0
4
4
3
0
1
0
0
144,830
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_experiment_api.py
unit.test_experiment_api.MockSaveBatch
class MockSaveBatch(MockLabKey): api = "saveAssayBatch.api" default_action = "assay" default_success_body = { "batches": [ { "lsid": "urn:lsid:labkey.com:Experiment.Folder-1721:50666e45-609f-1033-ba4a-ca4935e31f28", "createdBy": "", "created": "2015/10/29 12:17:50", "name": "python batch 7", "modified": "2015/10/29 12:17:51", "modifiedBy": "", "comment": None, "id": 139, "runs": [ { "dataOutputs": [], "dataRows": [ { "Treatment Group": None, "Start Date": None, "Height _inches_": None, "Comments": None, "Status of Infection": None, "Country": None, "Gender": None, "Group Assignment": None, "Participant ID": None, "Date": None, }, { "Treatment Group": None, "Start Date": None, "Height _inches_": None, "Comments": None, "Status of Infection": None, "Country": None, "Gender": None, "Group Assignment": None, "Participant ID": None, "Date": None, }, { "Treatment Group": None, "Start Date": None, "Height _inches_": None, "Comments": None, "Status of Infection": None, "Country": None, "Gender": None, "Group Assignment": None, "Participant ID": None, "Date": None, }, ], "dataInputs": [], "created": "2015/10/29 12:17:50", "materialInputs": [ { "lsid": "urn:lsid:labkey.com:AssayRunMaterial.Folder-1721:Unknown", "role": "Sample", "created": "2015/10/19 18:21:57", "name": "Unknown", "modified": "2015/10/19 18:21:57", "id": 7641, } ], "lsid": "urn:lsid:labkey.com:GeneralAssayRun.Folder-1721:50666e47-609f-1033-ba4a-ca4935e31f28", "materialOutputs": [], "createdBy": "", "name": "python upload", "modified": "2015/10/29 12:17:51", "modifiedBy": "", "comment": None, "id": 1673, "properties": {}, } ], "properties": {"ParticipantVisitResolver": None, "TargetStudy": None}, } ], "assayId": 2809, }
class MockSaveBatch(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
83
0
83
4
82
0
4
4
3
0
1
0
0
144,831
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.MockExecuteSQL
class MockExecuteSQL(MockLabKey): api = "executeSql.api"
class MockExecuteSQL(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
1
0
0
144,832
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_experiment_api.py
unit.test_experiment_api.TestSaveBatch
class TestSaveBatch(unittest.TestCase): def setUp(self): data_rows = [] # Generate the Run object(s) run = Run() run.name = "python upload" run.data_rows = data_rows run.properties["RunFieldName"] = "Run Field Value" # Generate the Batch object(s) batch = Batch() batch.runs = [run] batch.properties["PropertyName"] = "Property Value" self.service = MockSaveBatch() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": '{"assayId": 12345, "batches": [{"batchProtocolId": null, "comment": null, "created": null, "createdBy": null, "modified": null, "modifiedBy": null, "name": null, "properties": {"PropertyName": "Property Value"}, "runs": [{"name": "python upload", "properties": {"RunFieldName": "Run Field Value"}}]}]}', "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), assay_id, batch] def test_success(self): test = self success_test( test, self.service.get_successful_response(), save_batch, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), save_batch, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), save_batch, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), save_batch, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), save_batch, *self.args, **self.expected_kwargs )
class TestSaveBatch(unittest.TestCase): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
7
0
13
1
11
0
1
0.03
1
7
7
0
6
3
6
78
81
10
69
18
62
2
28
18
21
1
2
0
6
144,833
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.MockDeleteRows
class MockDeleteRows(MockLabKey): api = "deleteRows.api"
class MockDeleteRows(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
1
0
0
144,834
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.MockInsertRows
class MockInsertRows(MockLabKey): api = "insertRows.api"
class MockInsertRows(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
1
0
0
144,835
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.MockSelectRows
class MockSelectRows(MockLabKey): api = "getQuery.api" default_success_body = '{"columnModel": [{"align": "right", "dataIndex": "Participant ID", "editable": true , "header": "Participant ID", "hidden": false , "required": false , "scale": 10 , "sortable": true , "width": 60 }] , "formatVersion": 8.3 , "metaData": {"description": null , "fields": [{"autoIncrement": false , "calculated": false , "caption": "Participant ID", "conceptURI": null , "defaultScale": "LINEAR", "defaultValue": null , "dimension": false , "excludeFromShifting": false , "ext": {} , "facetingBehaviorType": "AUTOMATIC", "fieldKey": "Participant ID", "fieldKeyArray": ["Participant ID"] , "fieldKeyPath": "Participant ID", "friendlyType": "Integer", "hidden": false , "inputType": "text", "isAutoIncrement": false , "isHidden": false , "isKeyField": false , "isMvEnabled": false , "isNullable": true , "isReadOnly": false , "isSelectable": true , "isUserEditable": true , "isVersionField": false , "jsonType": "int", "keyField": false , "measure": false , "mvEnabled": false , "name": "Participant ID", "nullable": true , "protected": false , "rangeURI": "http://www.w3.org/2001/XMLSchema#int", "readOnly": false , "recommendedVariable": false , "required": false , "selectable": true , "shortCaption": "Participant ID", "shownInDetailsView": true , "shownInInsertView": true , "shownInUpdateView": true , "sqlType": "int", "type": "int", "userEditable": true , "versionField": false }] , "id": "Key", "importMessage": null , "importTemplates": [{"label": "Download Template", "url": ""}] , "root": "rows", "title": "Demographics", "totalProperty": "rowCount"} , "queryName": "Demographics", "rowCount": 224 , "rows": [{ "Participant ID": 133428 } , { "Participant ID": 138488 } , { "Participant ID": 140163 } , { "Participant ID": 144740 } , { "Participant ID": 150489 } ] , "schemaName": "lists"}'
class MockSelectRows(MockLabKey): pass
1
0
0
0
0
0
0
0.33
1
0
0
0
0
0
0
9
3
0
3
3
2
1
3
3
2
0
1
0
0
144,836
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.MockUpdateRows
class MockUpdateRows(MockLabKey): api = "updateRows.api"
class MockUpdateRows(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
1
0
0
144,837
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.TestDeleteRows
class TestDeleteRows(unittest.TestCase): def setUp(self): self.service = MockDeleteRows() rows = "{id:1234}" self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": '{"queryName": "' + query + '", "rows": "' + rows + '", "schemaName": "' + schema + '"}', "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), schema, query, rows] def test_success(self): test = self success_test( test, self.service.get_successful_response(), delete_rows, True, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), delete_rows, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), delete_rows, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), delete_rows, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), delete_rows, *self.args, **self.expected_kwargs )
class TestDeleteRows(unittest.TestCase): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
7
0
12
1
11
0
1
0
1
5
5
0
6
3
6
78
76
8
68
16
61
0
21
16
14
1
2
0
6
144,838
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_experiment_api.py
unit.test_experiment_api.TestLoadBatch
class TestLoadBatch(unittest.TestCase): def setUp(self): self.service = MockLoadBatch() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": '{"assayId": 12345, "batchId": 54321}', "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), assay_id, batch_id] def test_success(self): test = self success_test( test, self.service.get_successful_response(), load_batch, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), load_batch, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), load_batch, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), load_batch, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), load_batch, *self.args, **self.expected_kwargs )
class TestLoadBatch(unittest.TestCase): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
7
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
67
6
61
15
54
0
20
15
13
1
2
0
6
144,839
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestDrop
class TestDrop(unittest.TestCase): schema_name = "lists" query_name = "TheTestList" def setUp(self): class MockDrop(MockLabKey): api = "deleteDomain.api" default_action = domain_controller default_success_body = {} self.service = MockDrop() payload = {"schemaName": self.schema_name, "queryName": self.query_name} self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": json.dumps(payload, sort_keys=True), "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [ mock_server_context(self.service), self.schema_name, self.query_name, ] def test_success(self): test = self success_test( test, self.service.get_successful_response(), drop, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), drop, *self.args, **self.expected_kwargs )
class TestDrop(unittest.TestCase): def setUp(self): pass class MockDrop(MockLabKey): def test_success(self): pass def test_unauthorized(self): pass
5
0
14
1
13
0
1
0
1
2
2
0
3
3
3
75
49
7
42
16
37
0
18
16
13
1
2
0
3
144,840
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestConditionalFormatSave
class TestConditionalFormatSave(unittest.TestCase): schema_name = "lists" query_name = "TheTestList_cf" def setUp(self): self.test_domain = Domain( **{ "container": "TestContainer", "description": "A Test Domain", "domain_id": 5314, "fields": [{"name": "theKey", "rangeURI": "int"}], } ) self.test_domain.fields[0].conditional_formats = [ # create conditional format using our utility for a QueryFilter conditional_format( background_color="fcba03", bold=True, italic=True, query_filter=QueryFilter("theKey", 200), strike_through=True, text_color="f44e3b", ), # create conditional format using our utility for a QueryFilter list conditional_format( background_color="fcba03", bold=True, italic=True, query_filter=[ QueryFilter("theKey", 500, QueryFilter.Types.GREATER_THAN), QueryFilter("theKey", 1000, QueryFilter.Types.LESS_THAN), ], strike_through=True, text_color="f44e3b", ), ] class MockSave(MockLabKey): api = "saveDomain.api" default_action = domain_controller default_success_body = {} self.service = MockSave() payload = { "domainDesign": self.test_domain.to_json(), "queryName": self.query_name, "schemaName": self.schema_name, } self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": json.dumps(payload, sort_keys=True), "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [ mock_server_context(self.service), self.schema_name, self.query_name, self.test_domain, ] def test_success(self): test = self success_test( test, self.service.get_successful_response(), save, True, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), save, *self.args, **self.expected_kwargs )
class TestConditionalFormatSave(unittest.TestCase): def setUp(self): pass class MockSave(MockLabKey): def test_success(self): pass def test_unauthorized(self): pass
5
0
27
2
24
1
1
0.03
1
5
5
0
3
4
3
75
88
10
76
17
71
2
20
17
15
1
2
0
3
144,841
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestConditionalFormatCreate
class TestConditionalFormatCreate(unittest.TestCase): def setUp(self): self.domain_definition = { "kind": "IntList", "domainDesign": { "name": "TheTestList_cf", "fields": [ { "name": "theKey", "rangeURI": "int", "conditionalFormats": [ { "filter": encode_conditional_format_filter( QueryFilter("theKey", 500) ), "textColor": "f44e3b", "backgroundColor": "fcba03", "bold": True, "italic": True, "strikethrough": False, } ], } ], }, } class MockCreate(MockLabKey): api = "createDomain.api" default_action = domain_controller default_success_body = self.domain_definition self.service = MockCreate() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": json.dumps(self.domain_definition, sort_keys=True), "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.domain_definition] def test_success(self): test = self success_test( test, self.service.get_successful_response(), create, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), create, *self.args, **self.expected_kwargs )
class TestConditionalFormatCreate(unittest.TestCase): def setUp(self): pass class MockCreate(MockLabKey): def test_success(self): pass def test_unauthorized(self): pass
5
0
21
2
19
0
1
0
1
3
3
0
3
4
3
75
66
7
59
14
54
0
16
14
11
1
2
0
3
144,842
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/domain.py
labkey.domain.PropertyDescriptor
class PropertyDescriptor: def __init__(self, **kwargs): self.concept_uri = kwargs.pop("concept_uri", kwargs.pop("conceptURI", None)) formats = kwargs.pop("conditional_formats", kwargs.pop("conditionalFormats", [])) format_instances = [] for f in formats: format_instances.append(ConditionalFormat(**f)) self.conditional_formats = format_instances self.container = kwargs.pop("container", None) self.default_display_value = kwargs.pop( "default_display_value", kwargs.pop("defaultDisplayValue", None) ) self.default_scale = kwargs.pop("default_scale", kwargs.pop("defaultScale", None)) self.default_value = kwargs.pop("default_value", kwargs.pop("defaultValue", None)) self.default_value_type = kwargs.pop( "default_value_type", kwargs.pop("defaultValueType", None) ) self.description = kwargs.pop("description", None) self.dimension = kwargs.pop("dimension", None) self.disable_editing = kwargs.pop("disable_editing", kwargs.pop("disableEditing", None)) self.exclude_from_shifting = kwargs.pop( "exclude_from_shifting", kwargs.pop("excludeFromShifting", None) ) self.faceting_behavior_type = kwargs.pop( "faceting_behavior_type", kwargs.pop("facetingBehaviorType", None) ) self.format = kwargs.pop("format", None) self.hidden = kwargs.pop("hidden", None) self.import_aliases = kwargs.pop("import_aliases", kwargs.pop("importAliases", None)) self.label = kwargs.pop("label", None) self.lookup_container = kwargs.pop("lookup_container", kwargs.pop("lookupContainer", None)) self.lookup_description = kwargs.pop( "lookup_description", kwargs.pop("lookupDescription", None) ) self.lookup_query = kwargs.pop("lookup_query", kwargs.pop("lookupQuery", None)) self.lookup_schema = kwargs.pop("lookup_schema", kwargs.pop("lookupSchema", None)) self.measure = kwargs.pop("measure", None) self.mv_enabled = kwargs.pop("mv_enabled", kwargs.pop("mvEnabled", None)) self.name = kwargs.pop("name", None) self.ontology_uri = kwargs.pop("ontology_uri", kwargs.pop("ontologyURI", None)) self.phi = kwargs.pop("phi", None) self.prevent_reordering = kwargs.pop( "prevent_reordering", kwargs.pop("preventReordering", None) ) self.property_id = kwargs.pop("property_id", kwargs.pop("propertyId", None)) self.property_uri = kwargs.pop("property_uri", kwargs.pop("propertyURI", None)) validators = kwargs.pop("property_validators", kwargs.pop("propertyValidators", [])) validator_instances = [] for v in validators: validator_instances.append(PropertyValidator(**v)) self.property_validators = validator_instances self.range_uri = kwargs.pop("range_uri", kwargs.pop("rangeURI", None)) self.recommended_variable = kwargs.pop( "recommended_variable", kwargs.pop("recommendedVariable", None) ) self.redacted_text = kwargs.pop("redacted_text", kwargs.pop("redactedText", None)) self.required = kwargs.pop("required", None) self.scale = kwargs.pop("scale", None) self.search_terms = kwargs.pop("search_terms", kwargs.pop("searchTerms", None)) self.semantic_type = kwargs.pop("semantic_type", kwargs.pop("semanticType", None)) self.set_dimension = kwargs.pop("set_dimension", kwargs.pop("setDimension", None)) self.set_exclude_from_shifting = kwargs.pop( "set_exclude_from_shifting", kwargs.pop("setExcludeFromShifting", None) ) self.set_measure = kwargs.pop("set_measure", kwargs.pop("setMeasure", None)) self.shown_in_details_view = kwargs.pop( "shown_in_details_view", kwargs.pop("shownInDetailsView", None) ) self.shown_in_insert_view = kwargs.pop( "shown_in_insert_view", kwargs.pop("shownInInsertView", None) ) self.shown_in_update_view = kwargs.pop( "shown_in_update_view", kwargs.pop("shownInUpdateView", None) ) self.type_editable = kwargs.pop("type_editable", kwargs.pop("typeEditable", None)) self.url = kwargs.pop("url", None) def to_json(self, strip_none=True): # TODO: Likely only want to include those that are not None data = { "conceptURI": self.concept_uri, "container": self.container, "defaultDisplayValue": self.default_display_value, "defaultScale": self.default_scale, "defaultValue": self.default_value, "defaultValueType": self.default_value_type, "description": self.description, "dimension": self.dimension, "disableEditing": self.disable_editing, "excludeFromShifting": self.exclude_from_shifting, "facetingBehaviorType": self.faceting_behavior_type, "format": self.format, "hidden": self.hidden, "importAliases": self.import_aliases, "label": self.label, "lookupContainer": self.lookup_container, "lookupDescription": self.lookup_description, "lookupQuery": self.lookup_query, "lookupSchema": self.lookup_schema, "measure": self.measure, "mvEnabled": self.mv_enabled, "name": self.name, "ontologyURI": self.ontology_uri, "phi": self.phi, "preventReordering": self.prevent_reordering, "propertyId": self.property_id, "propertyURI": self.property_uri, "rangeURI": self.range_uri, "recommendedVariable": self.recommended_variable, "redactedText": self.redacted_text, "required": self.required, "scale": self.scale, "searchTerms": self.search_terms, "semanticType": self.semantic_type, "setDimension": self.set_dimension, "setExcludeFromShifting": self.set_exclude_from_shifting, "setMeasure": self.set_measure, "shownInDetailsView": self.shown_in_details_view, "shownInInsertView": self.shown_in_insert_view, "shownInUpdateView": self.shown_in_update_view, "typeEditable": self.type_editable, "url": self.url, } json_formats = [] for f in self.conditional_formats: json_formats.append(f.to_json()) data["conditionalFormats"] = json_formats json_validators = [] for p in self.property_validators: json_validators.append(p.to_json()) data["propertyValidators"] = json_validators return strip_none_values(data, strip_none)
class PropertyDescriptor: def __init__(self, **kwargs): pass def to_json(self, strip_none=True): pass
3
0
69
4
65
1
3
0.01
0
2
2
0
2
44
2
2
139
8
130
58
127
1
65
58
62
3
0
1
6
144,843
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/exceptions.py
labkey.exceptions.QueryNotFoundError
class QueryNotFoundError(RequestError): default_msg = "Query Resource Not Found"
class QueryNotFoundError(RequestError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
3
2
0
2
2
1
0
2
2
1
0
3
0
0
144,844
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/exceptions.py
labkey.exceptions.RequestAuthorizationError
class RequestAuthorizationError(RequestError): default_msg = "Authorization Failed"
class RequestAuthorizationError(RequestError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
3
2
0
2
2
1
0
2
2
1
0
3
0
0
144,845
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/exceptions.py
labkey.exceptions.RequestError
class RequestError(exceptions.RequestException): default_msg = "Server Error" def __init__(self, server_response, **kwargs): """ :type server_response: Response """ super().__init__(**kwargs) # base class allows for kwargs 'request' and 'response' self.response = server_response self.server_exception = None if self.response is not None: msg = self.default_msg try: decoded = self.response.json() if "exception" in decoded: # use labkey server error message if available msg = decoded["exception"] self.server_exception = decoded except ValueError: # no valid json to decode pass self.message = "{0}: {1}".format(self.response.status_code, msg) else: self.message = "No response received" def __str__(self): return str(self.message)
class RequestError(exceptions.RequestException): def __init__(self, server_response, **kwargs): ''' :type server_response: Response ''' pass def __str__(self): pass
3
1
14
2
9
3
3
0.3
1
3
0
5
2
3
2
3
31
5
20
9
17
6
19
9
16
4
2
3
5
144,846
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/exceptions.py
labkey.exceptions.ServerContextError
class ServerContextError(RequestError): def __init__(self, server_context, inner_exception): self.message = self._get_message(server_context, inner_exception) self.exception = inner_exception @staticmethod def _get_message(server_context, e): switcher = { exceptions.ConnectionError: "Failed to connect to server. Ensure the server_context domain, context_path, " "and SSL are configured correctly.", exceptions.InvalidURL: "Failed to parse URL. Context is " + str(server_context), exceptions.SSLError: "Failed to match server SSL configuration. Ensure the server_context is configured correctly.", } # #12 Pass through the exception message if available return switcher.get( type(e), str(e) if str(e) else "Please verify server_context is configured correctly.", )
class ServerContextError(RequestError): def __init__(self, server_context, inner_exception): pass @staticmethod def _get_message(server_context, e): pass
4
0
8
0
7
1
2
0.06
1
5
0
0
1
2
2
5
18
1
16
7
12
1
7
6
4
2
3
0
3
144,847
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/exceptions.py
labkey.exceptions.ServerNotFoundError
class ServerNotFoundError(RequestError): default_msg = "Server resource not found. Please verify context path and project path are valid"
class ServerNotFoundError(RequestError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
3
2
0
2
2
1
0
2
2
1
0
3
0
0