//
//
//
/// @brief A help function used to initialize the log file in the constructor.
//
/// @return None.
//
void log_file_handler::init_log_file()
{
	#pragma omp critical
	switch(!manager.file_system::exists()
	       && config -> output_mode()
	       && log_file_ready)
	{
		case true:
//
		set_fixed();
		log_file << "\nCatalyst ver. "
				 << CATALYST_VERSION
				 << "\n- Compilation number = "
				 << COMPILATION_NUMBER
				 << std::endl;
//
		write_title_bar("General settings", 80);
		log_file << "- Invoked in                          = "
				 << config -> work_dir()
				 << "\n- By                                  = "
				 << config -> check_current_username()
				 << "\n- From                                = "
				 << config -> check_current_hostname()
				 << "\n- At                                  = "
				 << config -> check_current_time()
				 << "- Number of tasks requested           = "
				 << config -> tasks()
				 << "\n- Memory available at the starting up = "
				 << config -> check_free_memory()
				 << " of "
				 << config -> check_total_memory()
				 << " GB"
				 << "\n- Number of CPUs available            = "
				 << config -> check_current_cpus()
				 << "\n- Log file                            = "
				 << config -> ctrl_key(config -> output_mode())
				 << "\n- Log filename                        = "
				 << config -> log_file()
				 << "\n- Debug mode                          = "
				 << config -> ctrl_key(config -> debug_mode())
				 << "\n- Scratch directory                   = "
				 << config -> scratch_dir()
				 << "\n- SCF convergence criteria            = "
				 << config -> scf_convergence_criteria()
				 << "\n- Numeric precision                   = "
				 << config -> numeric_precision()
				 << "/"
				 << tools::max_precision()
				 #if defined(USE_OMP)
				 << "\n- Open multi-processing               = on"
				 #else
				 << "\n- Open multi-processing               = off"
				 #endif
				 #if defined(USE_MPI)
				 << "\n- Message passing interface           = on"
				 #else
				 << "\n- Message passing interface           = off"
				 #endif
				 << "\n- Settings memory usage               = "
				 << tools::kB(config -> my_size())
				 << " kB"
				 << "\n" << std::endl;
	}
}
Exemplo n.º 2
0
void format_disk(void)
{
  if (force_f != YES && conf->open_files)
    fatal("Files open on drive");

  if (force_f != YES && f.removable == OFF
   && ((defined_format & REMOVABLE) == 0 || newf.removable == OFF))
  {
    changed_format = defined_format; /* Only for format_f */
    if (format_f || reconfig_f)
    {
      fatal("Changes requested for nonremovable drive");
    }
  }

  /* fill new format structure and check for changes */
  return_val = make_newf();
  if (return_val) {
    /* Could not make the disk as requested */
    if (return_val == ERRL_BADFORMAT)
      return_msg = "Aborted: Impossible format for disk";
    else if (return_val == ERRL_NOMEM)
      return_msg = "Aborted: Not enough memory for the disk";
    if (disk_bad) {
      warning("Impossible format for disk - restoring old format");
      memcpy(&newf, &f, sizeof f);
      WriteNewFormat();
    }
    return;
  }

  if (!disk_bad && !format_f && !reconfig_f) {
    if (!changed_format) {
      if (verbose > 0)
        warning("No change in format - disk remains untouched");
    }
    else {
      if (changed_format & WRITE_PROTECTION)
        set_write_protect();
      if (changed_format & REMOVABLE)
        set_fixed();
      if (changed_format & MAX_PART_SIZES) {
        if (f.size) {
          if (!SavingDiskAllocate(f.sectors))
            error("Failed to rearrange memory");
        }
        else
          ConfigMaxAlloc();
      }
    }
    return;
  }

  /* If Disk will be disabled */
  /* !!!! Move this before the code to adjust parameterf for resize */
  if (!newf.size) {
    if (!f.size) {
      /* If was disabled also before */
      configure_drive();
      if (verbose > 1)
        printf("New configuration saved for later use\n");
    } else {
      /* If disk now get's disabled */
      if (!licence_to_kill()) {
        return_val = ERRL_NO_LICENCE;
        return;
      }
      disable_disk();
    }
    return;
  }

  if (format_f || disk_bad) {
    if (!data_on_disk)
      WriteNewFormat();
    else
      Resize();
  }
  else if (reconfig_f) {
    ReConfig();
    if (f.size)
      RefreshBootSector();
    if (verbose > 1)
      printf("Drive %c: reconfigured\n", drive);
  }
}
Exemplo n.º 3
0
KDMShutdown::KDMShutdown( int mode, QWidget* _parent, const char* _name,
			  const char* _shutdown, 
			  const char* _restart)
     : FDialog( _parent, _name, true)
{
     shutdown = _shutdown;
     restart  = _restart;
     int h = 10, w = 0;
     QFrame* winFrame = new QFrame( this);
     winFrame->setFrameStyle( QFrame::WinPanel | QFrame::Raised);
     QBoxLayout* box = new QBoxLayout( winFrame, QBoxLayout::TopToBottom, 
				       10, 10);
     QString shutdownmsg =  klocale->translate( "Shutdown or restart?");
     if( mode == KDMConfig::RootOnly) {
	  shutdownmsg += '\n';
	  shutdownmsg += klocale->translate( "(Enter Root Password)");
     }
     label = new QLabel( shutdownmsg, winFrame);
     set_fixed( label);
     h += label->height() + 10;
     w = label->width();

     box->addWidget( label, 0, AlignCenter);

     QFrame* sepFrame = new QFrame( this);
     sepFrame->setFrameStyle( QFrame::HLine| QFrame::Sunken);
     h += sepFrame->height(); 
     box->addWidget( sepFrame);

     btGroup = new QButtonGroup( /* this */);
     
     QRadioButton *rb;
     rb = new QRadioButton( winFrame /*btGroup*/);
     rb->setText( klocale->translate("Shutdown"));
     set_min( rb);
     rb->setFocusPolicy( StrongFocus);
     // Default action
     rb->setChecked( true);
     rb->setFocus();
     cur_action = shutdown;
     
     h += rb->height() + 10;
     w = QMAX( rb->width(), w);

     box->addWidget( rb);
     btGroup->insert( rb);
     rb = new QRadioButton( winFrame /*btGroup*/);
     rb->setText( klocale->translate("Shutdown and restart"));
     set_min( rb);
     rb->setFocusPolicy( StrongFocus);
     h += rb->height() + 10;
     w = QMAX( rb->width(), w);

     box->addWidget( rb);
     btGroup->insert( rb);
     rb = new QRadioButton( winFrame /*btGroup*/);
     rb->setText( klocale->translate("Restart X Server"));//better description
     set_min( rb);
     rb->setFocusPolicy( StrongFocus);
     h += rb->height() + 10;
     w = QMAX( rb->width(), w);

     box->addWidget( rb);
     btGroup->insert( rb);

     // Passwd line edit
     if( mode == KDMConfig::RootOnly) {
	  pswdEdit = new QLineEdit( winFrame);
	  //set_min( pswdEdit);
	  pswdEdit->setMinimumHeight( pswdEdit->sizeHint().height());
	  pswdEdit->setEchoMode( QLineEdit::NoEcho);
	  /*QColorGroup   passwdColGroup(
	       QApplication::palette()->normal().foreground(),
	       QApplication::palette()->normal().background(),
	       QApplication::palette()->normal().light(),
	       QApplication::palette()->normal().dark(),
	       QApplication::palette()->normal().mid(),
	       QApplication::palette()->normal().base(),
	       QApplication::palette()->normal().base());
	  QPalette passwdPalette( passwdColGroup, passwdColGroup, 
				  passwdColGroup);
	  pswdEdit->setPalette( passwdPalette);
	  */
	  pswdEdit->setFocusPolicy( StrongFocus);
	  pswdEdit->setFocus();
	  h+= pswdEdit->height() + 10;
	  box->addWidget( pswdEdit);
     }

     QBoxLayout* box3 = new QBoxLayout( QBoxLayout::LeftToRight, 10);
     box->addLayout( box3);

     okButton = new QPushButton( klocale->translate("OK"), winFrame);
     set_min( okButton);
     okButton->setFocusPolicy( StrongFocus);
     cancelButton = new QPushButton( klocale->translate("Cancel"), winFrame);
     set_min( cancelButton);
     //cancelButton->setDefault( true);
     cancelButton->setFocusPolicy( StrongFocus);
     h += cancelButton->height() + 10;
     w = QMAX( (okButton->width() + 10 + cancelButton->width()), w);

     box3->addWidget( okButton);
     box3->addWidget( cancelButton);
     // Connections
     connect( okButton, SIGNAL(clicked()), SLOT(bye_bye()));
     connect( cancelButton, SIGNAL(clicked()), SLOT(reject()));
     connect( btGroup, SIGNAL(clicked(int)), SLOT(rb_clicked(int)));
     if( mode == KDMConfig::RootOnly) {
	  okButton->setEnabled( false);
	  connect( pswdEdit, SIGNAL( returnPressed()), this, SLOT( pw_entered()));
     } else
	  cancelButton->setFocus();
     resize( 20 + w, h);
     winFrame->setGeometry( 0, 0, width(), height());
}