Beispiel #1
0
 def testLog(self):
     with testing.mktemp('.pml') as logfile:
         cmd.log_open(logfile)
         cmd.do('_ color blue')
         cmd.log('hello world')
         cmd.log_close()
         lines = filter(None, map(str.strip, open(logfile)))
         self.assertEqual(lines, ['color blue', 'hello world'])
 def testLog(self):
     with testing.mktemp('.pml') as logfile:
         cmd.log_open(logfile)
         cmd.do('_ color blue')
         cmd.log('hello world')
         cmd.log_close()
         lines = [_f for _f in map(str.strip, open(logfile)) if _f]
         self.assertEqual(lines, ['color blue', 'hello world'])
Beispiel #3
0
 def testResume(self):
     with testing.mktemp('.pml') as logfile:
         with open(logfile, 'w') as f:
             print >> f, 'bg yellow'
         cmd.resume(logfile)
         self.assertEqual('yellow', cmd.get('bg_rgb'))
         cmd.log('hello world')
         cmd.log_close()
         lines = filter(None, map(str.strip, open(logfile)))
         self.assertEqual(lines, ['bg yellow', 'hello world'])
 def testResume(self):
     with testing.mktemp('.pml') as logfile:
         with open(logfile, 'w') as f:
             print('bg yellow', file=f)
         cmd.resume(logfile)
         self.assertEqual('yellow', cmd.get('bg_rgb'))
         cmd.log('hello world')
         cmd.log_close()
         lines = [_f for _f in map(str.strip, open(logfile)) if _f]
         self.assertEqual(lines, ['bg yellow', 'hello world'])
 def testResume(self):
     with testing.mktemp('.pml') as logfile:
         with open(logfile, 'w') as f:
             print('bg yellow', file=f)
         cmd.resume(logfile)
         self.assertEqual('yellow', cmd.get('bg_rgb'))
         cmd.log('hello world')
         cmd.log_close()
         lines = [_f for _f in map(str.strip, open(logfile)) if _f]
         self.assertEqual(lines, ['bg yellow', 'hello world'])
Beispiel #6
0
 def callback(*args):
     code = var_code.get()
     type = get_trunc(var_type)
     if type == 'pdb':
         code += var_chain.get()
     try:
         result = cmd.fetch(code, type=type)
         if result == -1:
             raise CmdException('You entered an invalid pdb code: ' + code)
     except CmdException as e:
         import tkMessageBox
         tkMessageBox.showerror('Error', str(e), parent=self)
         return
     cmd.log('fetch %s, type=%s, async=0\n' % (code, type))
     if not var_keep.get():
         self.destroy()
Beispiel #7
0
 def callback(*args):
     code = var_code.get()
     type = get_trunc(var_type)
     if type in ('pdb', 'cif'):
         code += var_chain.get()
     if type == 'cif':
         cmd.set('assembly', var_assembly.get())
     try:
         result = cmd.fetch(code, var_name.get(), type=type)
         if result == -1:
             raise CmdException('You entered an invalid pdb code: ' + code)
     except CmdException as e:
         tkMessageBox.showerror('Error', str(e), parent=self)
         return
     cmd.log('fetch %s, type=%s, async=0\n' % (code, type))
     if not var_keep.get():
         self.destroy()
    def testLog2(self):
        """
        Tests robustness of different logging methods:
        1) Python implementation (cmd.log) vs. C implementation (PLog, via cmd.do)
        2) pml vs. py syntax
        3) handling of quoted input (''' broken in 1.8.2)
        """
        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.fragment('gly')
        cmd.orient()
        cmd.show_as('spheres')

        for ext in ['.pml', '.py']:
            with testing.mktemp(ext) as logfile:
                cmd.log_open(logfile)
                cmd.do('_ color blue')
                cmd.do('/cmd.color("yellow", "elem O")')
                cmd.do('cmd.color("""green""",' " '''elem N''')")
                cmd.log('bg red\n')
                cmd.log('', 'cmd.color(\'magenta\', "hydro")\n')
                cmd.log_close()

                cmd.color('white')
                cmd.bg_color('white')

                if ext == '.pml':
                    cmd.do('@' + logfile)
                else:
                    cmd.do('run ' + logfile)

                img = self.get_imagearray()
                self.assertImageHasColor('blue', img)
                self.assertImageHasColor('yellow', img)
                self.assertImageHasColor('green', img)
                self.assertImageHasColor('red', img)
                self.assertImageHasColor('magenta', img)
                self.assertImageHasNotColor('white', img)
    def testLog2(self):
        """
        Tests robustness of different logging methods:
        1) Python implementation (cmd.log) vs. C implementation (PLog, via cmd.do)
        2) pml vs. py syntax
        3) handling of quoted input (''' broken in 1.8.2)
        """
        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.fragment('gly')
        cmd.orient()
        cmd.show_as('spheres')

        for ext in ['.pml', '.py']:
            with testing.mktemp(ext) as logfile:
                cmd.log_open(logfile)
                cmd.do('_ color blue')
                cmd.do('/cmd.color("yellow", "elem O")')
                cmd.do('cmd.color("""green""",' " '''elem N''')")
                cmd.log('bg red\n')
                cmd.log('', 'cmd.color(\'magenta\', "hydro")\n')
                cmd.log_close()

                cmd.color('white')
                cmd.bg_color('white')

                if ext == '.pml':
                    cmd.do('@' + logfile)
                else:
                    cmd.do('run ' + logfile)

                img = self.get_imagearray()
                self.assertImageHasColor('blue', img)
                self.assertImageHasColor('yellow', img)
                self.assertImageHasColor('green', img)
                self.assertImageHasColor('red', img)
                self.assertImageHasColor('magenta', img)
                self.assertImageHasNotColor('white', img)