Ctrl+] in gexpect

时间:2017-08-30 20:31:52

标签: go

    tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager) {
        @Override
        public void onTabSelected(TabLayout.Tab tab){
            super.onTabReselected(tab);
            int tabIconColor = ContextCompat.getColor(MainActivity.this,R.color.prehipertension);
            tab.getIcon().setColorFilter(tabIconColor, PorterDuff.Mode.SRC_IN);
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab){
            super.onTabUnselected(tab);
            int tabIconColor = ContextCompat.getColor(MainActivity.this,R.color.blancoTransparencia);
            tab.getIcon().setColorFilter(tabIconColor, PorterDuff.Mode.SRC_IN);
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            int tabIconColor = ContextCompat.getColor(MainActivity.this,R.color.blanco);
            tab.getIcon().setColorFilter(tabIconColor, PorterDuff.Mode.SRC_IN);
        }
    });

    viewPager.setCurrentItem(0);

I am running a command from a VM to a remote server. This is done with virsh console to the server and gexepect to login, run the command and then logout. My issue comes when trying to exit the console between the hosts. Virsh asks for CTRL +] in order to exit the console. I discovered that the octal for that is \035 and try sending that but nothing happens. I also specify child.Close() which should close the spawned process, which would be the console command, but i still get nothing. The terminal just hangs after the Password is inputted. Everything is executed as expected up until def send_mail(self, target, subject, body, *file_names): """ send a mail with files to the target @param target: send the mail to the target @param subject: mail's subject @param file_names= list of files to send """ msg = MIMEMultipart() msg['From'] = self.mail msg['To'] = target msg['Subject'] = subject body_part = MIMEText(body, 'plain') msg.attach(body_part) for file_name in file_names: f = open(file_name, 'rb') ctype, encoding = mimetypes.guess_type(file_name) if ctype is None or encoding is not None: ctype = 'application/octet-stream' maintype, subtype = ctype.split('/', 1) # in case of a text file if maintype == 'text': part = MIMEText(f.read(), _subtype=subtype) # in case of an image file elif maintype == 'image': part = MIMEImage(f.read(), _subtype=subtype) # in case of an audio file elif maintype == 'audio': part = MIMEAudio(f.read(), _subtype=subtype) # any other file else: part = MIMEBase(maintype, subtype) part.set_payload(f.read()) encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(file_name)) msg.attach(part) f.close() # ssl server doesn't support or need tls, so don't call server_ssl.starttls() self.server_ssl.sendmail(self.mail, target, msg.as_string()) self.server_ssl.quit() . My command is run on the remote server in the background, and logs off back to the OS login screen, but never terminates the virsh console to the remote host.

How would I go about sending CTRL +] through gexpect to exit a virsh console?

0 个答案:

没有答案