Begin main...
(logger=None)
| 143 | |
| 144 | |
| 145 | def main(logger=None): |
| 146 | """ |
| 147 | Begin main... |
| 148 | """ |
| 149 | if logger is None: |
| 150 | logger = LoggingUtil.create_log(__name__) |
| 151 | |
| 152 | if is_running("get_censys_files.py"): |
| 153 | """ |
| 154 | Check to see if a download is in process... |
| 155 | """ |
| 156 | logger.warning("Can't run due to get_files running. Goodbye!") |
| 157 | exit(0) |
| 158 | |
| 159 | if is_running(os.path.basename(__file__)): |
| 160 | """ |
| 161 | Check to see if a previous attempt to parse is still running... |
| 162 | """ |
| 163 | logger.warning("I am already running! Goodbye!") |
| 164 | exit(0) |
| 165 | |
| 166 | # Make the relevant database connections |
| 167 | RMC = RemoteMongoConnector.RemoteMongoConnector() |
| 168 | |
| 169 | ip_manager = IPManager.IPManager(RMC) |
| 170 | |
| 171 | # Verify that the get_files script has a recent file in need of parsing. |
| 172 | jobs_collection = RMC.get_jobs_connection() |
| 173 | |
| 174 | status = jobs_collection.find_one({"job_name": "censys"}) |
| 175 | if status["status"] != "DOWNLOADED": |
| 176 | logger.warning("The status is not set to DOWNLOADED. Goodbye!") |
| 177 | exit(0) |
| 178 | |
| 179 | now = datetime.now() |
| 180 | print("Starting: " + str(now)) |
| 181 | logger.info("Starting...") |
| 182 | |
| 183 | # Collect the list of available zones |
| 184 | zones = ZoneManager.get_distinct_zones(RMC) |
| 185 | |
| 186 | logger.info("Zones: " + str(len(zones))) |
| 187 | |
| 188 | # Get the current configuration information for Marinus. |
| 189 | config_collection = RMC.get_config_connection() |
| 190 | |
| 191 | configs = config_collection.find({}) |
| 192 | orgs = [] |
| 193 | for org in configs[0]["SSL_Orgs"]: |
| 194 | orgs.append(org) |
| 195 | |
| 196 | logger.info("Orgs: " + str(len(orgs))) |
| 197 | |
| 198 | # Obtain the name of the decompressed file. |
| 199 | filename_f = open(FILENAME_FILE, "r") |
| 200 | decompressed_file = filename_f.readline() |
| 201 | filename_f.close() |
| 202 |
no test coverage detected