diff --git a/farmosnws.admin.inc b/farmosnws.admin.inc index 52ac697..0256b2d 100644 --- a/farmosnws.admin.inc +++ b/farmosnws.admin.inc @@ -46,7 +46,7 @@ function farmosnws_admin_form() { 'no' => 'No', ), '#description' => t('Delete the National Weather Service XML feed after it has been processed.'), - '#default_value' => variable_get('farmosnws_delete_xml', 'Yes'), + '#default_value' => variable_get('farmosnws_delete_xml', 'yes'), ); return system_settings_form($form); @@ -57,11 +57,11 @@ function farmosnws_admin_form() { * Validate the module settings */ function farmosnws_admin_form_validate($form, &$form_state) { + // validate that the work directory exists and can be created $weatherfeedsdir = $form_state['values']['farmosnws_weather_feeds_dir']; $direxist = farmosnws_create_feed_dir($weatherfeedsdir); if ( $direxist == FALSE ){ - // watchdog('farmosnws', 'Unable to create the weather feed directory.', array(), WATCHDOG_ERROR, NULL); form_set_error('farmosnws_weather_feeds_dir', 'The weather feed directory cannot be created. Please verify that Drupal as write permissions and try again.'); } } // end if diff --git a/farmosnws.info b/farmosnws.info index 74c1896..b6691de 100644 --- a/farmosnws.info +++ b/farmosnws.info @@ -2,7 +2,8 @@ name = FarmOS NWS description = Imports data from the National Weather Service into Drupal for use by FarmOS. core = 7.x package = farmOS -version = 7.x-2.0-beta7 +version = 7.x-2.0 +dependencies[] = farm dependencies[] = farm_quantity dependencies[] = farm_log_observation diff --git a/farmosnws.module b/farmosnws.module index 530babd..f7c72d1 100644 --- a/farmosnws.module +++ b/farmosnws.module @@ -73,6 +73,7 @@ function farmosnws_create_feed_dir($feedpath) { function farmosnws_get_xml() { $weatherfeedsdir = variable_get('farmosnws_weather_feeds_dir'); + // TO DO: Add converter for schema to actual path // $weatherfeedsdir = file_create_url($weatherfeedsdir); $locations = variable_get('farmosnws_locations', ''); @@ -81,13 +82,12 @@ function farmosnws_get_xml() { foreach ($location_array as $loc) { // remove carriage returns and new lines $loc = str_replace(" ", "", str_replace("\r", "", str_replace("\n", "", $loc))); - // $loc = str_replace(" ", "", $loc); + // build URL to connect to NWS $weather_feed_name = $weatherfeedsdir . '/' . uniqid($loc, FALSE) . '.xml'; $url = "http://w1.weather.gov/xml/current_obs/" . $loc . ".xml"; watchdog('farmosnws', $url, array(), WATCHDOG_DEBUG, NULL); - watchdog('farmosnws', 'Getting weather data for ' . $loc, array(), WATCHDOG_INFO, NULL); $response = drupal_http_request($url, array()); @@ -109,7 +109,6 @@ function farmosnws_get_xml() { file_put_contents($weather_feed_name, $response->data); watchdog('farmosnws', 'Weather data saved to ' . $weather_feed_name, array(), WATCHDOG_INFO, NULL); - // farmosnws_load_xml($weather_feed_name); farmosnws_convert_xml_2_csv($weather_feed_name); } else { @@ -123,11 +122,9 @@ function farmosnws_get_xml() { /** * * @feedfilename string File name that will be split into smaller feeds - * */ function farmosnws_convert_xml_2_csv($feedfilename) { // read the files in the unprocessed directory - // $rawfiles = scandir('filename'); $csvfilename = $feedfilename . '.csv'; try{ @@ -275,3 +272,4 @@ function farmosnws_convert_xml_2_csv($feedfilename) { } } +